Consulting

Results 1 to 8 of 8

Thread: Need Help with Find and Replace Code in Word for text within Parenthesis

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Apr 2011
    Posts
    72
    Location

    Need Help with Find and Replace Code in Word for text within Parenthesis

    Hi all,

    I would like to bold text within parentheses to also include the text to be highlighted in red.

    I found a couple of options to do this but it doesn't work at all. Don't know if the problem is with the Find option or the Replace with option.

    Probably both are wrong.

    Thank you in advance for your assistance.





    Sub Macro2()
    '
    ' Macro to highlight text with parenthesis
    
    
    '
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = "\(*\)"
            .Replacement.Text = "\1"
            .Forward = True
            .Wrap = wdFindContinue
            .Font.Bold = True
            .Font.ColorIndex = wdRed
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = True
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •