●概要●
ショートカットメニューは、CommandBarオブジェクトのTypeプロパティがmsoBarTypePopupのものになります。このオブジェクトのEnabledプロパティを利用して、全てのショートカットメニューを使用不可にすることができます。
構文 オブジェクト.Enabled = False
設定項目 内容
オブジェクト CommandBarオブジェクト
次のサンプルは、CommandBarsコレクションに対して、ループ処理を行っています。CommandBarオブジェクトのTypeプロパティがmsoBarTypePopupの場合、Not演算子を利用して、使用可・不可を切り替えています。
●サンプル●
Sub Sample()
Dim tempCommandBar As Office.CommandBar
On Error Resume Next
For Each tempCommandBar In Application.CommandBars
If tempCommandBar.Type = msoBarTypePopup Then
tempCommandBar.Enabled = Not tempCommandBar.Enabled
End If
Next
End Sub