Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 07-26-2020, 08:16 AM
eduzs eduzs is offline Find/remove underline with specific color Windows 10 Find/remove underline with specific color Office 2019
Expert
Find/remove underline with specific color
 
Join Date: May 2017
Posts: 266
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/remove underline with specific color Remove white text background (keeping the font color and page color intact cc3125 Word 1 10-26-2015 06:44 PM
Find/remove underline with specific color VBA Table – Search All Tables - Find & Replace Text in Table Cell With Specific Background Color jc491 Word VBA 8 09-30-2015 06:10 AM
Find instance of a word in a specific style and change its color hwg Word VBA 7 02-20-2014 10:59 PM
Find/remove underline with specific color remove color from find/replace? Cobb78 Word 1 05-26-2012 06:16 PM
How to remove the UNDERLINE from a hyperlink text? Learner7 PowerPoint 3 05-17-2010 09:35 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:56 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft