Add items to context menu

  • Thread starter Thread starter Fred Jacobowitz
  • Start date Start date
F

Fred Jacobowitz

Excel 2003
How do I add items to the context menu that appears when I right click. I
would like to add items that will run a vba function just as I can with
keystrokes using the Application.Onkey function.
Thank you,
Fred Jacobowitz
 
That commandbar is called "Cell".

I saved this from a previous post:

This kind of thing might help:

Option Explicit
Sub auto_open()
With Application.CommandBars("cell")
On Error Resume Next
.Controls("DumpToFile").Delete
On Error GoTo 0

With .Controls.Add(Type:=msoControlButton, temporary:=True)
.BeginGroup = True
.Caption = "DumpToFile"
.OnAction = "'" & ThisWorkbook.Name & "'!yourmacronamehere"
End With
End With
End Sub
Sub auto_close()
With Application.CommandBars("cell")
On Error Resume Next
.Controls("DumpToFile").Delete
On Error GoTo 0
End With
End Sub
Sub yourmacronamehere()
MsgBox "hi from your macro!"
End Sub
 

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

Back
Top