How do I delete a command button using Word VBA?

可紊 提交于 2019-12-10 17:44:01

问题


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

How can I delete this button using VBA?


回答1:


This should do it :

For Each o In ActiveDocument.InlineShapes      

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

Next



回答2:


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.



来源:https://stackoverflow.com/questions/755247/how-do-i-delete-a-command-button-using-word-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!