VBA Word macro replacing text

  • Thread starter Thread starter Mudd
  • Start date Start date
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?
 
This news group is devoted to the use of VBA in Microsoft Access, the
database product. If you have not already done so, you might want to post
your question in one of the Word News Groups, all of which begin with:
microsoft.public.word
 
Back
Top