ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Add items to context menu (https://www.excelbanter.com/excel-worksheet-functions/84638-add-items-context-menu.html)

Fred Jacobowitz

Add items to context menu
 
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



Dave Peterson

Add items to context menu
 
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


Fred Jacobowitz wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 04:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com