全部显示

CommandBarButton 对象

         
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 对象。