Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Macro Multiple Document Manipulation?

Status
Not open for further replies.

Dijinn

Programmer
Apr 4, 2003
2
TR

Hello there,
I've written a word macro that will swap out one word style with another one specified by a user. Problem is, this is much to slow, we have way too many documents... I'd like it to do this style swap on every doc file in a user specified directory. Can anyone point me in the right direction?

I've included my macro for your reference...

Sub StyleSwap()
'
' ChangeDocumentStyles Macro
' Macro created {4.2.2003} by {Taylor Holmes}
'
' Purpose: To provide a way to quickly find and replace specified
' styles and replace them with another specified style by the user.

' Prompt the user for the style to find
Dim OriginalStyle As String
Dim ReplaceStyle As String
Dim msgPrompt1 As String
Dim msgPrompt2 As String
Dim msgTitle As String
Dim Continue As String


StartReplace:
msgPrompt1 = "Please enter the style name you'd like to replace."
msgPrompt2 = "Please enter the style name you'd like to replace it with."
msgPrompt3 = "Would you like to replace another style?"
msgTitle = "SRM: Style Replace Macro"

OriginalStyle = InputBox(msgPrompt1, msgTitle)
If OriginalStyle = "" Then GoTo EndRoutine

ReplaceStyle = InputBox(msgPrompt2, msgTitle)
If ReplaceStyle = "" Then GoTo EndRoutine

' Use the active Word document.
With ActiveDocument.Content.Find
.Style = ActiveDocument.Styles(OriginalStyle)
.Replacement.Style = ActiveDocument.Styles(ReplaceStyle)
.Execute Replace:=wdReplaceAll
End With

Continue = MsgBox(msgPrompt3, vbYesNo, msgTitle)

If Continue = vbYes Then GoTo ChangeDocumentStyles

EndRoutine:

End Sub

Thanks for your help on this in advance!!
Dijinn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top