Thread: [Solved] Word VBA - Ignore MsgBox
View Single Post
 
Old 11-07-2018, 10:24 PM
crazzyapple crazzyapple is offline Windows 7 64bit Office 2010
Novice
 
Join Date: Nov 2018
Posts: 2
crazzyapple is on a distinguished road
Default 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
Reply With Quote