Find and Replace with VBA

I

info

Hi All,

I use an Script which Finds som words and replace it.

For every Word to replace i use the following code:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Pollen"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll


THe Problem is that i have to replace six words. I can repeat this code
in the script, but the message box "Would you replace: yes/no" appears
for every word. Is there a possibility to replace the words
automativally without any message box?

Thanks for answers
 
H

Helmut Weber

Hi,

you don't need more than this:

Sub Test5003xy()
With ActiveDocument.Range.Find
.Text = "Pollen"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
End Sub

For your apparently recorded macro,
it would be
..wrap = wdFindcontinue

See in addition:
http://word.mvps.org/faqs/macrosvba/ModifyRecordedMacro.htm

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
I

info

Guten abend,

ich nehme mal an sie verstehen deutsch :)

vielen dank für den Tipp, funktioniert jetzt Prima. Das ist eine
große Hilfe :)

Viele Grüße
Tobias
 

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