View Single Post
 
Old 07-18-2016, 09:48 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
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

Come to that you could simply use
Code:
    With Selection.Font
        .Underline = wdUnderlineNone
        .StrikeThrough = False
    End With
which will remove underlining and strikethough from the selected text. Or for the main story range
Code:
    With ActiveDocument.Range.Font
        .Underline = wdUnderlineNone
        .StrikeThrough = False
    End With
If you want to use .Find then note that this does not limit the search to the end of the selected text, so test for the range being in the selection e.g.
Code:
Dim oRng As Range
    Set oRng = Selection.Range
    With oRng.Find
        .Font.StrikeThrough = True
        Do While .Execute
            If oRng.InRange(Selection.Range) Then
                oRng.Font.StrikeThrough = False
                oRng.Collapse 0
            End If
        Loop
    End With
    Set oRng = Selection.Range 'Reset the range
    With oRng.Find
        .Font.Underline = wdUnderlineSingle
        Do While .Execute
            If oRng.InRange(Selection.Range) Then
                oRng.Font.Underline = wdUnderlineNone
                oRng.Collapse 0
            End If
        Loop
    End With
Or for the whole main story range the test is not required e.g.
Code:
Dim oRng As Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
        .Font.StrikeThrough = True
        Do While .Execute
            oRng.Font.StrikeThrough = False
            oRng.Collapse 0
        Loop
    End With
    Set oRng = ActiveDocument.Range 'Reset the range
    With oRng.Find
        .Font.Underline = wdUnderlineSingle
        Do While .Execute
            oRng.Font.Underline = wdUnderlineNone
            oRng.Collapse 0
        Loop
    End With
__________________
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