Context menu for chart is missing

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
 
J

jnewby72

Well, I've researched and answered my own question. There is a bit of
code (4 lines) that does the trick at the following link...

http://www.excelforum.com/showthread.php?t=539152

The code is...

dim cb as commandbar

for each cb in applications.commandbars
cb.enabled = true
next cb

I would still like to know why the menus in question were not enabled
with the code listed. Anybody have a clue?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top