VB and VBA Users Source Code: Customising Excel's right click menus
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Customising Excel's right click menus
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Wednesday, October 31, 2001
Hits:
1048
Category:
Unspecified
Article:
The following code demonstrates how to change the right click menu for an Excel Worksheet and Chart. To test this run the code below and go to a worksheet or a chart and right click it. 'Alters the right click menu in a worksheet Sub AlterWorkSheetPopup() Dim oCtrl As Object With Application.CommandBars("Cell") 'Clear the existing menus For Each oCtrl In .Controls oCtrl.Delete Next 'Add a new menu With .Controls.Add(msoControlButton) .Caption = "Test Routine" .OnAction = "Test" End With End With End Sub 'Alters the right click menu in a chart Sub AlterWorkChartPopup() Dim oCtrl As Object With Application.CommandBars("Plot Area") 'Clear the existing menus For Each oCtrl In .Controls oCtrl.Delete Next 'Add a new menu With .Controls.Add(msoControlButton) .Caption = "Test Routine" .OnAction = "Test" End With End With End Sub 'Routine will be called by the new menu items Sub Test() MsgBox "Test succeeded!" 'Reset the menus Application.CommandBars("Cell").Reset Application.CommandBars("Plot Area").Reset End Sub
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder