Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 10-06-2020, 09:32 PM
Cendrinne's Avatar
Cendrinne Cendrinne 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 2019
Competent Performer
vbYesNo, my script only acts on Yes, doesn't do anyting on No? Help
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Default Thanks Graham :)

Thank you for your effort. I'm so grateful.

It's progress. It's almost to what I need.
The danger in that script, is that it selects all the empty paragraph marks under it, & it doesn't pick up text List (text list meaning, it doesn't open the auto List fomat), but I do have titles beggining with numbers with tabs. So I ended up with numbers.

I'm trying to include also the vbYesNoCancel. With your script, I've figured out how to managed mine a little bit.

This is an example of titles numbers, text list. If you copy this in word, you will get paragraph marks where you see space below.

****If you use the script, to find (continued)**** ====> hoping to delete the whole sentence with the 1. tab and sentence.****

1. Significant accounting policies (continued)




2. Significant accounting policies (continued)




3. Significant accounting policies (continued)



4. Significant accounting policies (continued)



5. Significant accounting policies (continued)

This is my modified script that picks up text numbers, and moves forwards. But I can excecute Cancel, however, it does the same things as ''ansering No''.
Any insights?

Sub Delete_Sentence_if_Word_found()
Dim strTexts As String
Dim oRng As range
Dim bFound As Boolean
bFound = False
strTexts = InputBox("Enter texts to be found here: ")
Set oRng = ActiveDocument.range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = strTexts
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
While .Execute
bFound = True
oRng.Expand Unit:=wdParagraph
oRng.Select
ActiveDocument.ActiveWindow.ScrollIntoView Selection.range, True
If MsgBox("Are you sure to delete the sentence?", vbYesNoCancel) = vbYes Then
Selection.Delete
'Else: Exit Sub
'End If
'oRng.Collapse wdCollapseEnd
'.Execute
If (vbYesNoCancel) = vbCancel Then
Exit Sub
End If
End If
oRng.Collapse wdCollapseEnd
'.Execute
Wend
End With
If Not bFound Then
MsgBox "You have put a text that is not part of the document." & vbCr + vbCr _
& "Put another texte and try again.", vbInformation & vbOKOnly, "THE TEXT IS NOT IN THIS DOCUMENT"
End If
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
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 03:57 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