What am I doing wrong? Word 2003 on XP SP2.
I want a macro to change all occurances of Piano to be shown in bold and
red. I recorded the macro and it worked at that time. But using the macro
does not work. You can see that the replacement information such as bold
and color is not recorded.
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Piano"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
I tried
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Piano"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
With Selection.Find.Replacement
.Text = "\1"
.Font.Color = wdBlue
.Font.Bold = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
but that didn't work either.
Why does Word not record this correctly and how can I fix it?
Thank you!
Joy
Jay Freedman - 07 Sep 2006 03:54 GMT
See http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm,
especially the section "Fixing broken Replace macros".
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
>What am I doing wrong? Word 2003 on XP SP2.
>
[quoted text clipped - 49 lines]
>
>Joy