Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2006

Tip: Looking for answers? Try searching our database.

Find and Replace with VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
info@forsthaus-auerhahn.de - 24 Sep 2006 20:13 GMT
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
Helmut Weber - 24 Sep 2006 20:26 GMT
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

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

info@forsthaus-auerhahn.de - 24 Sep 2006 20:41 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.