Word 2002 macros no longer work

G

Guest

I am trying to change the heading styles used in a document to different
heading styles, ie Myheading2 to Myheading3. I wish to do this on a number
of documents so as a trial I created a macro which converted just one of the
headings on one of the documents using find and replace.
I can't get the macro to work. When I run it nothing appears to happen.
However when I go back to using find and replace manually I find all the
formatting of the styles is attached to the find and replace boxes. ie
Myheading2 is set to 16 point bold and the find box also shows that it is
looking for 16 point bold. Myheading3 is set to 14 point underline and so is
the replace box. The macro is apparently doing something.
I have set up and used this kind of macro many times when I used Word on an
XP setup. I now use Vista. Do I need to do something different on Vista?
 
J

Jay Freedman

The macro recorder has a bug that prevents it from recording any style or
formatting information in Find and Replace operations. See the section
"Fixing broken Replace macros" in
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm for
instructions on how to fix the macro. In your case, instead of adding .Font
and .Replacement.Font statements, you will need the statements

.Style = ActiveDocument.Styles("Myheading2")
.Replacement.Style = ActiveDocument.Styles("Myheading3")

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

Guest

Thank you both for the prompt replies.
I thought I had used that sort of macro before - It seems I hadn't. I have
looked at the reference you gave and it gives a very clear description of
what to do. Thanks again.
 

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