How can I avoid the Question dialog box?

G

Goody

I am developing a macro that uses repeated Search & Replace operations on a
selection to tailor the text. In it's current form, execution of the macro
requires the user to select Yes or No as an answer to the question "Do you
want to search the remainder of the document?" I can define the selection to
eliminate the need for user response, but I can't seem to avoid the dialog
box. What code accomplishes this?

Thanks,
Goody
 
B

Brian

Are you using something like this?

With ActiveDocument.Range.Find
.Text = "your text"
.Replacement.Text = "your replacement text"
.Execute Replace:=wdReplaceAll
End With


Brian
 
S

Shauna Kelly

Hi Goody

In your code, find the line that says
.Wrap = wdFindAsk
and change it to
.Wrap =wdFindContinue ' will do the whole document or range until it
gets back to the beginning
or
.Wrap =wdFindStop ' will process the relevant range and then stop.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
G

Goody

I was using the Selection object, which resulted from the macro recorder:

With Selection.Find
.Text = "find text"
.Replacement.Text = "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

I tried using ActiveDocument.Range, and the result is the same. I still get
the dialog box.

Thanks,
Goody
 
J

Jean-Guy Marcil

Goody was telling us:
Goody nous racontait que :
I am developing a macro that uses repeated Search & Replace
operations on a selection to tailor the text. In it's current form,
execution of the macro requires the user to select Yes or No as an
answer to the question "Do you want to search the remainder of the
document?" I can define the selection to eliminate the need for user
response, but I can't seem to avoid the dialog box. What code
accomplishes this?

What code are you using?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

Goody

Shauna Kelly said:
Hi Goody

In your code, find the line that says
.Wrap = wdFindAsk
and change it to
.Wrap =wdFindContinue ' will do the whole document or range until it
gets back to the beginning
or
.Wrap =wdFindStop ' will process the relevant range and then stop.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

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