View Single Post
 
Old 10-05-2018, 10:38 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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

The following will remove any type of underline. If the message box obscures the item drag it out of the way.

Code:
Sub Delete_Underlines()
' 'Graham Mayor - http://www.gmayor.com - Last updated - 06 Oct 2018
'
' Delete_Underlines Macro
' Will delete all underlines in Document except in Mail addresses (& hyperlinks ??)
Const strUline As String = "1|2|3|4|6|9|10|11|20|23|25|26|27|39|43|55"
Dim vUline As Variant
Dim oRng As Range
Dim oWord As Range
Dim i As Long
    vUline = Split(strUline, "|")
    For i = 0 To UBound(vUline)
        Set oRng = ActiveDocument.Range
        With oRng.Find
            .ClearFormatting
            .Font.Underline = CLng(vUline(i))
            .Replacement.ClearFormatting
            Do While .Execute()
                If oRng.Hyperlinks.Count = 0 Then
                    oRng.Select
                    If MsgBox("Do you want to remove underline from this instance", vbYesNo) = vbYes Then
                        oRng.Font.Underline = wdUnderlineNone
                    End If
                    oRng.Collapse 0
                End If
            Loop
        End With
    Next i
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