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

Macro to Replace the text in Word Document.

Status
Not open for further replies.

nag999

Programmer
Apr 16, 2003
33
IN
Hi All,

In MS Word document, I had a text object with text in it. I am replacing a word "Internet Knowledge Base" with other word "Internet-KB". I placed the replacing logic with in a macro. But when ever the macro is executed it is Prompting me with "Do you want to replace text" Yes or No. I want to suppress these message windows.So that user no need to press enter key for every replacement.

The macro code is as below.

Selection.ShapeRange.Select
ActiveDocument.Shapes("Text Box 56").Select
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Internet Knowledge Base"
.Replacement.Text = "Internet-KB"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll


Is there any way to suppress the prompts generated while replacing the text.

Any help is really appreciated.

Regards
Nagaraj
 
Hi nagaraj,

Put ...

Code:
Application.DisplayAlerts = False
... before the Find.Execute and ...

Code:
Application.DisplayAlerts = True
... afterwards to reset it,

Enjoy,
Tony

 
Hi Tony,

I got it.Thanks for your tip..

Thanx,
Nagaraj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top