Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #13  
Old 10-03-2018, 04:08 AM
gmayor's Avatar
gmayor gmayor is offline Macros from this Forum will not run. Windows 10 Macros from this Forum will not run. Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,143
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Your original message said that you wanted to remove underscores. Your example text displays underLINES and not underscores, which explains why nothing happens.
Try the following
Code:
Sub Delete_Underlines()
' 'Graham Mayor - http://www.gmayor.com - Last updated - 03 Oct 2018
'
' Delete_Underlines Macro
' Will delete all underlines in Document except in Mail addresses (& hyperlinks ??)

Dim oRng As Range
Dim oWord As Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
        .ClearFormatting
        .Font.Underline = wdUnderlineSingle
        .Replacement.ClearFormatting
        Do While .Execute()
            If oRng.Hyperlinks.Count = 0 Then
                oRng.Font.Underline = wdUnderlineNone
                oRng.Collapse 0
            End If
        Loop
    End With
lbl_Exit:
    Set oRng = Nothing
    Set oWord = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a sub-Forum for Office for Mac? IvanH Office 1 02-20-2014 11:31 PM
Macros from this Forum will not run. MS Windows forum? Joan64 Office 2 07-01-2013 10:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:25 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