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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop MS Word Macro?

Status
Not open for further replies.

TopHat2

Technical User
Joined
Jun 12, 2001
Messages
116
Location
GB
I have a small macro that I have written in MS Word 2000. The macro does a search then types a few characters. I need to put the macro into a loop, until it has searched the whole document. How do I do this?

Below is the text of the macro:

Sub Macro7()
'
' Macro7 Macro
' Macro recorded 10/09/02 by Les Bentley
'
Selection.HomeKey Unit:=wdStory
Selection.HomeKey Unit:=wdLine
Selection.Find.ClearFormatting
With Selection.Find
.Text = "targetGeom"
.Replacement.Text = "k 0 0"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
With Selection.Find
.Text = "k"
.Replacement.Text = "k 0 0"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="k 0 0"
Selection.TypeParagraph


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top