Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete a command button using Word VBA?

Tags:

ms-word

vba

I have a Word document that contains a command button named "update".

How can I delete this button using VBA?

like image 817
Paul Ellery Avatar asked Sep 16 '26 08:09

Paul Ellery


2 Answers

This should do it :

For Each o In ActiveDocument.InlineShapes      

   If o.OLEFormat.Object.Name = "update" Then
        o.Delete
    End If

Next
like image 186
Peter Avatar answered Sep 18 '26 22:09

Peter


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.

like image 21
Nilesh Deshmukh Avatar answered Sep 18 '26 21:09

Nilesh Deshmukh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!