View Single Post
 
Old 10-06-2020, 08:45 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,103
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 of
Default

Try the following
Code:
Sub Delete_Sentence_if_Word_found()
Dim strTexts As String
Dim oRng As Range
    strTexts = InputBox("Enter texts to be found here: ")
    Set oRng = ActiveDocument.Range
    With oRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        While .Execute(findText:=strTexts)
            oRng.Expand Unit:=wdSentence
            oRng.Select
            ActiveDocument.ActiveWindow.ScrollIntoView oRng, True
            If MsgBox("Are you sure to delete the sentence?", vbYesNo) = vbYes Then
                oRng.Text = ""
            End If
            oRng.Collapse wdCollapseEnd
        Wend
    End With
lbl_Exit:
    Set oRng = 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