View Single Post
 
Old 10-04-2018, 12:24 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub Delete_Underlines()
'A basic Word macro coded by Graham Mayor,
   'adapted by Greg Maxey, http://gregmaxey.com/word_tips.html, 10/4/2018
Dim oRng As Range
Dim oScope As Range
  Set oRng = Selection.Range
  Set oScope = oRng.Duplicate
  With oRng.Find
    .ClearFormatting
    .Font.Underline = wdUnderlineSingle
    .Replacement.ClearFormatting
    Do While .Execute()
      If oRng.InRange(oScope) Then
      If oRng.Hyperlinks.Count = 0 Then
        oRng.Select
        If MsgBox("Do you want to remove underline from this instance", vbYesNo, "Actio") = vbYes Then
          oRng.Font.Underline = wdUnderlineNone
        End If
        oRng.Collapse 0
      End If
      Else
        Exit Do
      End If
   Loop
  End With
lbl_Exit:
  Set oRng = Nothing
  Set oScope = Nothing
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote