Recording macros

P

plareau

I am trying to record very simple macros and it appears that part of the
macro is being recorded, but parts are not. For example, I opened the
recorder and recorded a macro to find any text in blue font. After the text
was found, I stopped the macro recorder. When I open up the macro to edit
it, there is no reference to "blue" in the macro instructions and, if I
attempt to run the macro, it does not work.

Similarly, I recorded a macro to find specified text and convert that text
to the hidden font. Again, when I open the macro to edit it, there is no
reference to such font and when I run the macro, it deletes the text rather
than hide it.

I strongly suspect there is something very basic about recording macros that
I don't know about or understand. Any assistance would be much appreciated.

Thank you.
 
J

Jay Freedman

I am trying to record very simple macros and it appears that part of the
macro is being recorded, but parts are not. For example, I opened the
recorder and recorded a macro to find any text in blue font. After the text
was found, I stopped the macro recorder. When I open up the macro to edit
it, there is no reference to "blue" in the macro instructions and, if I
attempt to run the macro, it does not work.

Similarly, I recorded a macro to find specified text and convert that text
to the hidden font. Again, when I open the macro to edit it, there is no
reference to such font and when I run the macro, it deletes the text rather
than hide it.

I strongly suspect there is something very basic about recording macros that
I don't know about or understand. Any assistance would be much appreciated.

Thank you.

You've run headlong into one of the most prominent bugs in the macro
recorder. See
http://word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm for help
in fixing the macros.
 
G

Graham Mayor

As Jay has indicated the macro recorder has faults and one of the more
noticable one concerns the imability to record the replacement function
fully. You will have to edit your macro by hand. The following example
should give you a clue how. This example converts 12 point Arial Bold to 11
Point Bookman Old Style Italic in Blue colour.

Sub ReplaceExample()

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'**********************
.Text = ""
.Font.Name = "Arial"
.Font.Bold = True
.Font.Size = "12"

.Replacement.Text = ""
.Replacement.Font.Name = "Bookman Old Style"
.Replacement.Font.Size = "11"
.Replacement.Font.Color = wdColorBlue
.Replacement.Font.Italic = True
'**********************
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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