I have a Word document that contains a command button named "update".
How can I delete this button using VBA?
thanks, Paul
I have a Word document that contains a command button named "update".
How can I delete this button using VBA?
thanks, Paul
This should do it :
For Each o In ActiveDocument.InlineShapes
If o.OLEFormat.Object.Name = "update" Then
o.Delete
End If
Next
I have tried this code. It runs without error, but the button does not get deleted. I have stepped through the code and the o.Delete command is executed. Just doesn't seem to do anything. Can you suggest what the problem could be?
Thanks, Chris
Hey Chris,
I think when you said 'Button Name' you ment 'Button Caption'; please try below code -
For Each o In ActiveDocument.InlineShapes
If o.OLEFormat.Object.Caption = "update" Then
o.Delete
End If
Next
Regards, Nilesh
PS: the caption is case sensitive, so you may want to check the case for caption.