CommandBarButton 对象

优质
小牛编辑
116浏览
2023-12-01

全部显示

CommandBars (CommandBar)
CommandBarControls (CommandBarControl)
CommandBarButton
CommandBarComboBox
CommandBarPopup

代表命令栏中的一个按钮控件。

使用 CommandBarButton 对象

Controls(index) 可返回一个CommandBarButton 对象;此处index 是该控件的索引号。(该控件的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 对象。