View Single Post
 
Old 07-26-2020, 08:16 AM
eduzs eduzs is offline Windows 10 Office 2019
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

This adaptation based on your code works but results in infinite loop
The Exit Do is not working.
Update: the code below does not work if the document have headers.
The document can have words underlined in up to 3 colors or none underlined, one of which is automatic. I need to remove only underlines that are not wdColorAutomatic.

Code:
Set oRng = ActiveDocument.range
With oRng.Find
    .Font.Underline = True
    .Forward = True
    .Wrap = wdFindContinue
    .Execute
Do While .Found
    If oRng.Font.UnderlineColor <> wdColorAutomatic Then
        oRng.Font.Underline = wdUnderlineNone
    End If
    If .Found = ActiveDocument.range.End Then Exit Do
    .Execute
Loop
End With
Update2:
Maybe this is impossible with find/found loop, with for/next loop (each word) I was able to get the task done, but takes a lot of time.
For now I chose to simply remove the entire underline.

Thanks!
__________________
Backup your original file before doing any modification.

Last edited by eduzs; 07-26-2020 at 05:12 PM.
Reply With Quote