#1
|
|||
|
|||
Word VBA - Ignore MsgBox
Hi;
I am using MS Word 2016 and I am trying to ignore a MsgBox, if the button is already deleted. This Sub is being called in another Sub. How the code is now, the message will always show. Any help will be greatly appreciated. Code:
Sub DeleteButton() Dim obj As Object Dim varResponse As Variant varResponse = MsgBox("Button will be deleted.") For Each obj In ActiveDocument.InlineShapes If varResponse = vbOK Then If obj.OLEFormat.Object.Name = "CommandButton1" Then obj.Delete End If End If Next End Sub |
#2
|
||||
|
||||
Move the message box to where you need to ask the question e.g.
Code:
Sub DeleteButton() Dim obj As Object Dim varResponse As Variant For Each obj In ActiveDocument.InlineShapes If obj.OLEFormat.Object.Name = "CommandButton1" Then varResponse = MsgBox("Button will be deleted.") If varResponse = vbOK Then obj.Delete End If Next End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
thank you gmayor
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem with Msgbox in VBA | Puzzled Programmer | Excel Programming | 6 | 09-06-2018 04:34 PM |
msgbox when deleting cells | Mikedk64 | Excel Programming | 11 | 07-13-2017 07:14 AM |
What happend to Ignore once (spell check) in Word 2013? | nick93 | Word | 2 | 07-05-2016 01:44 PM |
How to make word ignore a specific shape when printing? | ZAK | Word | 12 | 04-07-2014 03:14 PM |
Make MsgBox appear... | Jamtart | PowerPoint | 3 | 09-01-2012 08:21 AM |