macro to copy filtered styles

D

#DIV/0

Is there a way to loop through all styles in a specific doc or template and
copy them to another (doc or template) based on the fact that the style name
begins with, for example "MVP" ?
There's an example in the Help for OrganizerCopy that searches for a
specific style name:

Dim styleLoop As Style
For Each styleLoop In ActiveDocument.Styles
If styleLoop = "SubText" Then
Application.OrganizerCopy Source:=ActiveDocument.Name, _
Destination:="C:\Templates\Template1.dot", _
Name:="SubText", _
Object:=wdOrganizerObjectStyles
End If
Next styleLoop

Referencing the source and destination files is no problem but what can I
use to replace "SubText" with something like "MVP*" as the style name ?
 
H

Helmut Weber

Hi
If left(styleLoop, 3) = "MVP" Then

Sub Test49923()
Dim styleLoop As Style
For Each styleLoop In ActiveDocument.Styles
If Left(styleLoop, 3) = "MVP" Then
MsgBox styleLoop
Application.OrganizerCopy Source:=ActiveDocument.Name, _
Destination:="C:\editXP\normal.dot", _
Name:=styleLoop, _
Object:=wdOrganizerObjectStyles
End If
Next styleLoop
End Sub





--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top