Click to See Complete Forum and Search --> : Macro interrupt


iam70
January 29th, 2000, 07:07 PM
I have written a macro in Word 97 where all text is selected, certain characters are looked for and replaced. (see below)

The macro works find. However, at the end of the replace process, the macro stops and displays the window where it tells me that the selection had been searched and whether I want the process done for the rest of the document.

It is annoying that the macro stops and asks for the input. Is there any way that I can suppress this message. Especially, since as part of the macro the whole document is selected.

Thanks for your help. Any response is appreciated.

Issam

Selection.WholeStory
Selection.Font.Size = 12
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " "
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With

gedcke
February 29th, 2000, 05:29 PM
Wow ... there doesn't seem to be a flag to stop it from doing that ... how annoying is that!

Anyway, when all else fails, it's always useful to try a SendKeys event. I was able to make it work using that. In my example I ended up having to manually press Enter twice to get past the messages on the screen, so I had to do the following in front of the final command to execute the Replace, as below:

SendKeys "{enter}{enter}" Selection.Find.Execute Replace:=wdReplaceAll

iam70
March 3rd, 2000, 02:06 PM
Great Advice! That worked just fine. It all happens seemlessly. So thanks a lot.