Link to home
Start Free TrialLog in
Avatar of Cook09
Cook09Flag for United States of America

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cook09

ASKER

I'm not sure I understand what it all means, but it worked perfectly.

Thanks.