如何使用 Word VBA 删除命令按钮?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/755247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I delete a command button using Word VBA?
提问by Paul Ellery
I have a Word document that contains a command button named "update".
我有一个 Word 文档,其中包含一个名为“更新”的命令按钮。
How can I delete this button using VBA?
如何使用 VBA 删除此按钮?
回答by Peter
This should do it :
这应该这样做:
For Each o In ActiveDocument.InlineShapes
If o.OLEFormat.Object.Name = "update" Then
o.Delete
End If
Next
回答by Nilesh Deshmukh
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.
PS:标题区分大小写,因此您可能需要检查标题的大小写。