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!

Basic Word Macro to Replace

Status
Not open for further replies.

ljjtek

Technical User
Feb 26, 2001
35
US
This is not even remotely my area of expertise, but I have an incredibly large amount of documents that I could really use some VBS for... Basically I want to somehow automate a find and replace for a few things (ex: Find 'top' Replace 'bottom' and then Find 'over' Replace 'under') for this document and others like it. I'm sure this is a very basic, but really I'm lost..... I mean I can get to the Macro window, but then...?????Help? Please?
 
ljjtek,

You could try the following.

Sub find_replace()

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "top "
.Replacement.Text = "bottom "
.Forward = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "over "
.Replacement.Text = "under "
.Forward = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

End Sub



worked ok for me using word2000

HTH

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top