>I try to make a simple macro that repeatedly search an active document and
> make some editing each time the search success.
>
> How do I make the repeat loop?
>
> The macro looks like this:
Change it to this
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "No table output."
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute
Selection.TypeBackspace
Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend
Selection.TypeBackspace
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
If Selection.Text <> "" Then Selection.TypeBackspace
Selection.TypeBackspace
Wend
End With
Selection.HomeKey Unit:=wdStory
End Sub
The trick to this is that the Execute method of the Find object returns a
boolean value depending on whether it found something. You can branch
depending on the result.
I've also change the Wrap property to wdFindStop, so that it doesn't try to
start again at the beginning of the document when the search reaches the
end.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Frank - 24 Feb 2005 10:13 GMT
Thank you very much for your solution. I just had to replase the "wend"
keyword with "loop" and then it worked just perfect.
Frank
> >I try to make a simple macro that repeatedly search an active document and
> > make some editing each time the search success.
[quoted text clipped - 37 lines]
> start again at the beginning of the document when the search reaches the
> end.