How do I customize the context menu?

G

Guest

I'd like to customize the context menu in excel (ie - to add and remove commands from the "right-click" menu), but I've been unable to find out how to do this. It does not seem possible to add or remove commands from the context menu via the "Tools -> Customize" menu as the context menu is not visible there. Any information anybody has on how to do this would be must appreciated. Thanks!
 
B

Bernie Deitrick

JJ,

The commandbar is actually called "Cell".

Here are two subs that show how to modify it. The first
will add a smiley-faced button that calls the subroutine named
JJMacro() from
the file MyFile.xls. To reset the Cell drop down menu, use the second
sub.

Bernie

Sub ChangeCellDropDown()
With Application.CommandBars("Cell")
..Reset
..Enabled = True
With .Controls.Add(Type:=msoControlButton, Before:=1)
..Caption = "JJ's Macro"
..Style = msoButtonIconAndCaption
..FaceId = 59
..OnAction = "MyFile.xls!JJMacro"
End With
End With
End Sub

Sub ResetCellDropDown()
Application.CommandBars("Cell").Reset
End Sub

HTH,
Bernie
MS Excel MVP

JJ said:
I'd like to customize the context menu in excel (ie - to add and
remove commands from the "right-click" menu), but I've been unable to
find out how to do this. It does not seem possible to add or remove
commands from the context menu via the "Tools -> Customize" menu as
the context menu is not visible there. Any information anybody has on
how to do this would be must appreciated. 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