Word 2010 VBA - Why does it format some but not all?

Attached is a document with a small macro below, that is supposed to change everything from an apostrophe ( ' ) to the end of the line,  into a different color.  There are two that work, toward the end.  The rest don't.

Sub Format_Text_CRs()

    Selection.HomeKey Unit:=wdStory
    Selection.WholeStory
    Selection.Style = ActiveDocument.Styles("Normal")
    With Selection.Font
         .Name = "Calibri"
          .Size = 10
          .Color = Selection.Font.Color = 8210719
          .Bold = True
    End With

With Selection.Find
    .ClearFormatting
    .Forward = True
    .MatchCase = True
    .MatchWholeWord = False
    .MatchWildcards = True
    With .Replacement
        .ClearFormatting
        .Font.Color = 6580480  'Teal Green (0,105,100)
        .Font.Bold = True
        .Font.Size = 10
'        .Font.Color = 35840  'Green
        .Font.Bold = True
    End With
    .Execute findText:="'*^13", ReplaceWith:="", _
        Format:=True, Replace:=wdReplaceAll
End With

End Sub

Open in new window

Maybe it's the smart quotes, but I tried to do a replace, and it said that the replace was successful, however when running the code, it still doesn't work.

Any ideas on why?
Format-Text.docx
Cook09Asked:
Who is Participating?
 
GrahamSkanConnect With a Mentor RetiredCommented:
Does this do what you want?
Sub Format_Text_CRs()

    Selection.HomeKey Unit:=wdStory
    Selection.WholeStory
    Selection.Style = ActiveDocument.Styles("Normal")
    With Selection.Font
         .Name = "Calibri"
          .Size = 10
          .Color = 8210719
          .Bold = True
    End With

With Selection.Find
    .ClearFormatting
    .Forward = True
    .MatchCase = True
    .MatchWholeWord = False
    .MatchWildcards = True
    With .Replacement
        .ClearFormatting
        .Font.Color = 6580480  'Teal Green (0,105,100)
        .Font.Bold = True
        .Font.Size = 10
'        .Font.Color = 35840  'Green
        .Font.Bold = True
    End With
    .Execute findText:="([‘']{1}*^13)", ReplaceWith:="\1", _
        Format:=True, Replace:=wdReplaceAll
End With

End Sub

Open in new window

0
 
Cook09Author Commented:
I'm not sure I understand what it all means, but it worked perfectly.

Thanks.
0
All Courses

From novice to tech pro — start learning today.