Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding underlined text in Word????

Status
Not open for further replies.

Rainman76

MIS
Mar 14, 2005
1
0
0
US
Anyone know how you might find underlined words in a word document? Once I find them I want to change the underlined color to red. I know how to do that (.Font.UnderlineColor = wdColorRed), just don't know how to find the underlined words.

Any help would be greatly appreciated.

Thanks!
 
Macro recorder creates this:

Code:
Sub Macro1()

    Selection.Find.ClearFormatting
    Selection.Find.Font.Underline = wdUnderlineSingle
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
End Sub
 
Code:
With ActiveDocument.Content.Find
    .Font.Underline = True
    .Text = ""
    With .Replacement
        .Font.UnderlineColor = wdColorRed
        .Text = ""
    End With
    .Execute Format:=True, Replace:=wdReplaceAll
End With

This does not use the Selection object, and therefore does not use screen resources. It simply makes all underlined text red. The .Text being "" means that all text i8s subject to it.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top