CommandBars.ActionControl プロパティ (Office)

OnAction プロパティが設定された実行中のプロシージャにする ので、CommandBarControl オブジェクトを取得します。 読み取り専用です。

注:

[!メモ] 一部の Microsoft Office アプリケーションにおける CommandBars の使用方法が、Microsoft Office Fluent ユーザー インターフェイスの新しいリボン コンポーネントによって置き換えられました。 詳細については、「Office Fluent リボンの概要」を参照してください。

構文

ActionControl

CommandBars オブジェクトを表す変数。

次の使用例は、 Custom という名前のコマンド バーを作成し、それに 3 つのボタンを追加した後、 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 のサポートおよびフィードバックを参照してください。