View Single Post
 
Old 05-24-2009, 04:46 AM
Bird_FAT's Avatar
Bird_FAT Bird_FAT is offline Office 2007
Expert
 
Join Date: Apr 2009
Location: South East
Posts: 271
Bird_FAT is on a distinguished road
Default

Quote:
Originally Posted by Bahir Barak View Post
OK , but when I done these changings in code and run the macro it gives this error :
((
Run-time error ,5560:
The Find What text contains a Pattern Match expression which is not valid.
))

AH - I see the problem - you've left wildcards as TRUE
Try this - it should work!!
Code:
Sub find_and_colour_brackets()
'
' Code written by Bird_FAT
'
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "("
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
 
    While Selection.Find.Execute
    Selection.Font.Color = wdColorRed
    Selection.Font.Italic = wdToggle
    Wend
 
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = ")"
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
 
    While Selection.Find.Execute
    Selection.Font.Color = wdColorRed
    Selection.Font.Italic = wdToggle
    Wend
 
End Sub
Reply With Quote