Find & Replace

R

Robert

I have recorded a search an replace macro, but I need to
loop this within a given document, until all the document
has been searched. The macro keeps halting after the first
search/replace.

Any help would be appreciated.
Regards
Robert
 
M

Mark Baird

Have you tried the following.

Selection.find.Wrap = wdFindContinue

I believe the following is the default property for
the "execute" method.

Selection.Find.Execute Replace:=wdReplaceAll


Mark Baird
 
D

Doug Robbins - Word MVP

Hi Robert,

Use Do While.Execute() = True, as in

' Macro to round all numbers in a document
' Macro created 19/7/00 by Doug Robbins
'
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[0-9]{1,}.[0-9]{3,}", MatchWildcards: =
True, Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Text = Round(Selection.Range.Text, 2)
Loop
End With

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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