Word VBA macro

M

Mudd

If I have a Word document with some text in the main part of the document,
and some text in a text box, I can use the Word menus to replace all the
text in the document and it works OK (by using Edit - Replace). If I record
a macro to do the same thing, it also works while the recording is in
progress. If I then run that macro, the text in the text box does not get
replaced. I can record a macro to explicitly select the text box and by
doing so, discovered that (in this instance anyway) that it is called
ActiveDocument.Shapes("Text Box 2"). I could add this line to the macro to
then replace the text in it but the problem is that this macro will not be
attached to this one document. It will be running against any 1 of about 30
documents all of which will have a text box with text to be replaced (as
well as text to be replaced in the main part of the document) and it isn't
necessarily going to be "Text Box 2" for all of them. Is there a way for a
VBA macro to determine the name of the text box at run time so that it can
be explicitly selected for the purposes of replaing the text in it?
 

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