Find and Replace Macros for formatting



Hello all,

Our goal is to find any text with formatting of Arial, bold Italic and 14
pts and replace that with a Heading 2 Style. If you record the macro the
steps work, but nothing happens when you play back the macro on another
document. My code is below.

Sub Macro1()
' Macro1 Macro
' Macro recorded 5/21/2008 by Genzyme Corporation
Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 2")
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = ""
.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
End Sub

YOur help will be appreciated.

Jay Freedman

There is a bug in the macro recorder for all versions except Word 2007. It
records ".Format = True" but fails to record any of the formatting
instructions that should accompany it.

See for an
explanation of how to insert the necessary instructions. You'll need

.Font.Name = "Arial"
.Font.Bold = True
.Font.Italic = True
.Font.Size = 14

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

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