Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 10-06-2020, 08:45 PM
gmayor's Avatar
gmayor gmayor 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: 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

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
 

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 01:51 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