Article ID: 183137
Article Last Modified on 8/21/2007
Sub ReplaceFont()
With Selection.Find
' Clear all previously set formatting for Find dialog box.
.ClearFormatting
' Set font to Find for replacement.
.Font.Name = "Times New Roman"
' Clear all previously set formatting for Replace dialog box.
.Replacement.ClearFormatting
' Set font to Replace found font.
.Replacement.Font.Name = "Arial"
' Dont find or replace any text.
.Text = ""
.Replacement.Text = ""
' The following parameters must be set as follows
' to find only text formatted for the specified font.
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
' Perform the find and replace.
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
NOTE: This macro does not prompt you before it changes the font. In order
to be prompted to replace each occurrence of the font, replace the
wdFindContinue constant in the .Wrap = statement with the wdFindAsk
constant.
181058 OFF98: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon vb vba vbe
Keywords: kbdtacode kbhowto kbmacroexample KB183137