Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 10-06-2020, 09:23 PM
Guessed's Avatar
Guessed Guessed is offline vbYesNo, my script only acts on Yes, doesn't do anyting on No? Help Windows 10 vbYesNo, my script only acts on Yes, doesn't do anyting on No? Help Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
 

Tags
vbyesno help



Similar Threads
Thread Thread Starter Forum Replies Last Post
vbYesNo, my script only acts on Yes, doesn't do anyting on No? Help Script Directory charlesdh Excel Programming 3 06-12-2018 01:36 PM
vbYesNo, my script only acts on Yes, doesn't do anyting on No? Help 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
vbYesNo, my script only acts on Yes, doesn't do anyting on No? Help Script Doesn't works on other machine ravininave Word 1 01-05-2011 01:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft