![]() |
|
#5
|
||||
|
||||
|
And to include a Cancel option by building on to Graham's code
Code:
Sub Delete_Sentence_if_Word_found()
Dim strTexts As String, oRng As Range, iResponse As Integer
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
iResponse = MsgBox("Are you sure to delete the sentence?", vbYesNoCancel)
If iResponse = vbYes Then
oRng.Text = ""
ElseIf iResponse = vbCancel Then
Exit Sub
End If
oRng.Collapse wdCollapseEnd
Wend
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
| Tags |
| vbyesno help |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Script Directory
|
charlesdh | Excel Programming | 3 | 06-12-2018 01:36 PM |
Outlook VBA Script
|
kcm5153 | Outlook | 1 | 04-07-2015 11:41 PM |
| Help with VBA script | nsyrax | Word VBA | 1 | 01-18-2014 03:38 AM |
| the character "v" when typed acts like ctrl-v. | jim redfield | Word | 1 | 09-22-2012 05:19 AM |
Script Doesn't works on other machine
|
ravininave | Word | 1 | 01-05-2011 01:45 PM |