CommandBarButton 对象 (Office)
代表命令栏中的一个按钮控件。
注意
某些 Microsoft Office 应用程序中对 CommandBars 的使用已由 Microsoft Office Fluent 用户界面的新功能区组件取代。 有关详细信息,请参阅 Office Fluent 功能区概述。
示例
使用 Controls (索引) ,其中 index 是控件的索引号,以返回 CommandBarButton 对象。 请注意,控件的 Type 属性必须是 msoControlButton。 假设名为 Custom 的命令栏上的第二个控件是一个按钮,以下示例将更改该按钮的样式。
Set c = CommandBars("Custom").Controls(2)
With c
If .Type = msoControlButton Then
If .Style = msoButtonIcon Then
.Style = msoButtonIconAndCaption
Else
.Style = msoButtonIcon
End If
End If
End With
注意
还可以使用 FindControl 方法返回 CommandBarButton 对象。
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。