![]() |
|
#1
|
||||
|
||||
![]()
Please use the # to add code tags when posting code.
Both the code I posted and Andrew's Cancel addition will delete autonumbered texts, if those sentences complete a paragraph. If they don't then you will also need to remove the numbering e.g 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: ", , "continued") 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 = "" oRng.ListFormat.RemoveNumbers ElseIf iResponse = vbCancel Then Exit Sub End If oRng.Collapse wdCollapseEnd Wend End With lbl_Exit: Set oRng = Nothing Exit Sub End Sub Without knowing what is in the paragraphs you can only program on the basis of what you do know.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
![]() |
Tags |
vbyesno help |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
charlesdh | Excel Programming | 3 | 06-12-2018 01:36 PM |
![]() |
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 |
![]() |
ravininave | Word | 1 | 01-05-2011 01:45 PM |