ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Right click menu (https://www.excelbanter.com/excel-programming/373193-right-click-menu.html)

ewagz

Right click menu
 
Is there a way to add an item (Macro) to the right cleick menu? The macro
will be calling a userform.

Any help would be appreciated!
--
EW - Analyst

Muhammed Rafeek M

Right click menu
 
Code to create the new shortcut menu item:

Add lines to the Workbook_Open procedure as follows:

If necessary, make an empty line above the existing code, and enter as the
first line the variable declaration:

Dim NewControl as CommandBarControl

The next line of code, which can be entered below your shortcut key code,
tells Excel that the variable is a new item (or control) to be added to the
right-click menu of a cell:

Set NewControl = Application.CommandBars("Cell").Controls.Add

Now some code to describe the new item:

With NewControl
.Caption = "Insert Date"
.OnAction = "Module1.MacroName"
.BeginGroup = True
End With

Pls do rate

"ewagz" wrote:

Is there a way to add an item (Macro) to the right cleick menu? The macro
will be calling a userform.

Any help would be appreciated!
--
EW - Analyst



All times are GMT +1. The time now is 01:28 AM.

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