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