View Single Post
 
Old 03-16-2015, 07:51 PM
Guessed's Avatar
Guessed Guessed is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I'm surprised that it does work because I didn't know that there was a Word constant for wdBoldSingle - you should be using a boolean there.

You can simplify the code to
Code:
Sub FormatMacro()
  Dim oRng As Word.Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<Life Insurance>"
    .Replacement.Text = ""
    .MatchWildcards = True
    .Format = True
    .Replacement.Font.Underline = wdUnderlineSingle
    .Execute Replace:=wdReplaceAll

    .Replacement.ClearFormatting
    .Text = "<2.4.9>"
    .Replacement.Font.Bold = True
    .Execute Replace:=wdReplaceAll
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote