Article ID: 131257
Article Last Modified on 10/11/2006
161440 XL97: How to Disable Shortcut Menus
Sub DisableShortcutMenus()
Dim i As Integer
Dim x As Integer
Dim y As Integer
On Error Resume Next
For i = 1 To 3 ' Loops through three times using the index number.
Application.ShortcutMenus(i).Enabled = False
Next i
For x = 6 To 9 ' Loops through four times using the index number.
Application.ShortcutMenus(x).Enabled = False
Next x
For y = 11 To 24 ' Loops through 14 times using the index number.
Application.ShortcutMenus(y).Enabled = False
Next y
With Application
' These are constants that do not fall in any sequential order
' so they need to be done separately using the constant string.
.ShortcutMenus(xlRowHeader).Enabled = False
.ShortcutMenus(xlModule).Enabled = False
.ShortcutMenus(xlDialogSheet).Enabled = False
.ShortcutMenus(xlColumnHeader).Enabled = False
End With
End Sub
Sub RestoreShortcutMenus()
Dim i As Integer
Dim x As Integer
Dim y As Integer
On Error Resume Next
For i = 1 To 3 ' Loops through three times using the index number.
Application.ShortcutMenus(i).Enabled = True
Next i
For x = 6 To 9 ' Loops through four times using the index number.
Application.ShortcutMenus(x).Enabled = True
Next x
For y = 11 To 24 ' Loops through 14 times using the index number.
Application.ShortcutMenus(y).Enabled = True
Next y
With Application
' These are constants that do not fall in any sequential order
' so they need to be done separately using the constant string.
.ShortcutMenus(xlRowHeader).Enabled = True
.ShortcutMenus(xlModule).Enabled = True
.ShortcutMenus(xlDialogSheet).Enabled = True
.ShortcutMenus(xlColumnHeader).Enabled = True
End With
End Sub
The following is a list of the Microsoft Excel 5.0 and 7.0 constants and
the values they represent.
Shortcut menu constant Constant Value ----------------------------------------- xlRowHeader -4153 xlModule -4141 xlDialogSheet -4116 xlColumnHeader -4110 xlToolbar 1 xlToolbarButton 2 xlWorksheetCell 3 xlWorkbookTab 6 xlMacroSheet 7 xlTitleBar 8 xlDesktop 9 xlWatchPane 11 xlImmediatePane 12 xlDebugCodePane 13 xlDrawingObject 14 xlButton 15 xlTextBox 16 xlChartSeries 17 xlChartTitles 18 xlPlotArea 19 xlEntireChart 20 xlAxis 21 xlGridline 22 xlFloor 23 xlLegend 24
ShortcutMenus
Additional query words: 5.00a 5.00c 7.00a XL7 XL5 XL
Keywords: kbcode kbhowto kbprogramming KB131257