J
jnewby72
The subject is a little misleading. The context menus that are missing
are the menus that popup from the axis, axis titles, legend, and chart
title. I am developing an application within Excel. I wanted to disable
all keyboard shortcuts, menus, and commandbars. Here is the code that I
used to disable the menus and commandbars
'CODE USED TO DISABLE MENUS AND COMMANDBARS
Public Sub DeleteMenus()
Dim lngError As Long 'error code
Dim cbrTemp As CommandBar
Dim cbrAll As CommandBars
Dim intCounter As Integer
'initialize variables
intCounter = 0
'get the commandbars collection
Set cbrAll = Application.CommandBars
'cycle through all the commandbars and menus
For Each cbrTemp In cbrAll
'check that the menu is enabled
If cbrTemp.Enabled = True Then
'counter for appending count to Key name
intCounter = intCounter + 1
'save the command bars name to the registry
VBA.SaveSetting APPNAME, PRIMARYSECTION & "\" & CMDBARKEY,
_
CMDBARSUBKEYS & CStr(intCounter), cbrTemp.Name
'disable the commandbar
cbrTemp.Enabled = False
End If
Next cbrTemp
End Sub
'CODE USED TO REINSTALL MENUS AND COMMANDBARS
Sub InstallMenus()
Dim cbrAll As CommandBars
Dim intCounter As Integer
Dim varArray As Variant
'get the commandbars collection
Set cbrAll = Application.CommandBars
'initialize the counter
intCounter = 1
'get all of the commandbar names from the registry
varArray = VBA.GetAllSettings(APPNAME, PRIMARYSECTION & "\" &
CMDBARKEY)
'loop through the returned set of commandbars
For intCounter = LBound(varArray) To UBound(varArray)
'enable the commandbar
cbrAll(varArray(intCounter, 1)).Enabled = True
'delete the key from the registry
VBA.DeleteSetting APPNAME, PRIMARYSECTION & "\" & CMDBARKEY,
CMDBARSUBKEYS & CStr(intCounter + 1)
Next intCounter
End Sub
I store the names of the menus that were originally enabled in the
registry; before, the application workbook was opened. So, when the
user closes the workbook application, the names of the menus can be
restored.
Can anyone help me to recover the menus that become visible when the
user right-clicks the legend, axis titles, chart title, gridlines, and
axes?
Thanks
are the menus that popup from the axis, axis titles, legend, and chart
title. I am developing an application within Excel. I wanted to disable
all keyboard shortcuts, menus, and commandbars. Here is the code that I
used to disable the menus and commandbars
'CODE USED TO DISABLE MENUS AND COMMANDBARS
Public Sub DeleteMenus()
Dim lngError As Long 'error code
Dim cbrTemp As CommandBar
Dim cbrAll As CommandBars
Dim intCounter As Integer
'initialize variables
intCounter = 0
'get the commandbars collection
Set cbrAll = Application.CommandBars
'cycle through all the commandbars and menus
For Each cbrTemp In cbrAll
'check that the menu is enabled
If cbrTemp.Enabled = True Then
'counter for appending count to Key name
intCounter = intCounter + 1
'save the command bars name to the registry
VBA.SaveSetting APPNAME, PRIMARYSECTION & "\" & CMDBARKEY,
_
CMDBARSUBKEYS & CStr(intCounter), cbrTemp.Name
'disable the commandbar
cbrTemp.Enabled = False
End If
Next cbrTemp
End Sub
'CODE USED TO REINSTALL MENUS AND COMMANDBARS
Sub InstallMenus()
Dim cbrAll As CommandBars
Dim intCounter As Integer
Dim varArray As Variant
'get the commandbars collection
Set cbrAll = Application.CommandBars
'initialize the counter
intCounter = 1
'get all of the commandbar names from the registry
varArray = VBA.GetAllSettings(APPNAME, PRIMARYSECTION & "\" &
CMDBARKEY)
'loop through the returned set of commandbars
For intCounter = LBound(varArray) To UBound(varArray)
'enable the commandbar
cbrAll(varArray(intCounter, 1)).Enabled = True
'delete the key from the registry
VBA.DeleteSetting APPNAME, PRIMARYSECTION & "\" & CMDBARKEY,
CMDBARSUBKEYS & CStr(intCounter + 1)
Next intCounter
End Sub
I store the names of the menus that were originally enabled in the
registry; before, the application workbook was opened. So, when the
user closes the workbook application, the names of the menus can be
restored.
Can anyone help me to recover the menus that become visible when the
user right-clicks the legend, axis titles, chart title, gridlines, and
axes?
Thanks