获取一个 CommandBarControl 对象,该对象的 OnAction 属性设置为当前正在运行的过程。 只读。
注意
某些 Microsoft Office 应用程序中对 CommandBars 的使用已由 Microsoft Office Fluent 用户界面的新功能区组件取代。 有关详细信息,请参阅 Office Fluent 功能区概述。
语法
表达式。ActionControl
表达 一个代表 CommandBars 对象的变量。
示例
此示例创建名为 Custom 的命令栏,向其添加三个按钮,然后使用 ActionControl 属性和 Tag 属性来确定上次单击的命令栏按钮。
Set myBar = CommandBars _ 
    .Add(Name:="Custom", Position:=msoBarTop, _ 
    Temporary:=True) 
Set buttonOne = myBar.Controls.Add(Type:=msoControlButton) 
With buttonOne 
    .FaceId = 133 
    .Tag = "RightArrow" 
    .OnAction = "whichButton" 
End With 
Set buttonTwo = myBar.Controls.Add(Type:=msoControlButton) 
With buttonTwo 
    .FaceId = 134 
    .Tag = "UpArrow" 
    .OnAction = "whichButton" 
End With 
Set buttonThree = myBar.Controls.Add(Type:=msoControlButton) 
With buttonThree 
    .FaceId = 135 
    .Tag = "DownArrow" 
    .OnAction = "whichButton" 
End With 
myBar.Visible = True
下面的子例程响应 OnAction 方法并确定最后单击的是哪一个命令栏按钮。
Sub whichButton() 
Select Case CommandBars.ActionControl.Tag 
    Case "RightArrow" 
        MsgBox ("Right Arrow button clicked.") 
    Case "UpArrow" 
        MsgBox ("Up Arrow button clicked.") 
    Case "DownArrow" 
        MsgBox ("Down Arrow button clicked.") 
End Select 
End Sub
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。