Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-27-2020, 07:41 AM
gmaxey gmaxey is offline Find/remove underline with specific color Windows 10 Find/remove underline with specific color Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

To catch headers, footers and other areas of a document you will need to loop through the storyranges. It is more complicated than the code below but this might work:

Code:
Sub Macro1()
Dim oRng As Range
  For Each oRng In ActiveDocument.StoryRanges
  With oRng.Find
    .Font.Underline = wdUnderlineSingle
    Do While .Execute
      If Not oRng.Font.UnderlineColor = wdColorAutomatic Then
        oRng.Font.Underline = wdUnderlineNone
       End If
       oRng.Collapse 0
    Loop
  End With
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Font.Underline = wdUnderlineWords
    Do While .Execute
      If Not oRng.Font.UnderlineColor = wdColorAutomatic Then
        oRng.Font.Underline = wdUnderlineNone
       End If
       oRng.Collapse 0
    Loop
  End With
  Next oRng
lbl_Exit:
  Exit Sub
End Sub

__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



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 11:22 PM.


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