Disabling shortcut menus

You may want to disable one or more shortcut menus while your application is running. For example, you may not want the user to access the commands by right-clicking a cell. If you want to disable all shortcut menus, use the following procedure, also available on this book's Web site:

Sub DisableShortcuts()

Dim cbar As CommandBar For Each cbar In Application.CommandBars If cbar.Type = msoBarTypePopup Then cbar.Enabled = False End If Next cbar End Sub

Disabling the shortcut menus remains between sessions. Therefore, you probably want to restore the shortcut menus before closing Excel. To restore the shortcut menus, modify the preceding procedure by setting Enabled to True.

0 0

Post a comment