When recording a macro a dialog box doesn't display

G

G Teachman

Hello,

When searching for a phrase in a highlighted selection of a document; if the
phrase is not found Word responds with a Yes/No dialog box basically saying
it didn't find the phrase would I like to search the remaining part of the
document. Select 'yes' to search the rest of the document, or no don't
search the rest of the document.

When creating a macro that does the same thing, the 'did not find' dialog
box does not display. So, I can't tell it to stop searching.

When I run a macro created to do this kind of thing, the dialog box does
show up. Since I want the answer to be 'No' all the time, this is annoying.

Does anyone know how to get all dialog boxes to show up when recording a
macro?

Thanks,
 
J

Jay Freedman

It's impossible to get the dialogs to show during recording; it's also
impossible to do certain other things, like editing graphics. That's just
the way the recorder is. You have to learn enough about VBA to write the
correct code without the recorder, or by modifying a recorded starting
point. See http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm
for some help with that.

In this particular case, a running macro that does a find or replace never
displays that message anyway. Instead, you put a line of code into the macro
to tell it what behavior to use. If you want the search to end when it
reaches the end of the document, then the .Wrap property of the .Find object
should be set to the value wdFindStop. The recorder always puts in the line

..Wrap = wdFindContinue

which you need to change in the macro editor.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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