ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Trigger Action when Standard Menu Item Selected? (https://www.excelbanter.com/excel-discussion-misc-queries/101009-trigger-action-when-standard-menu-item-selected.html)

Filibuster

Trigger Action when Standard Menu Item Selected?
 
I would like to execute some code when a standard menu items is selected
(like 'Protect Sheet'). Is there a way to trap on a menu item? Or, do I
essentially need to customize the standard menu item?

Ron de Bruin

Trigger Action when Standard Menu Item Selected?
 
Hi Filibust

You can try this example for 'Protect Sheet'
For reset use
Mycontrol.OnAction = ""



Sub test()
Dim Mycontrol As CommandBarControl

Set Mycontrol = Application.CommandBars("Worksheet Menu Bar").FindControl _
(ID:=893, Recursive:=True)

Mycontrol.OnAction = ThisWorkbook.Name & "!mymacro"
End Sub


Sub mymacro()
MsgBox "Hi"
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Filibuster" wrote in message ...
I would like to execute some code when a standard menu items is selected
(like 'Protect Sheet'). Is there a way to trap on a menu item? Or, do I
essentially need to customize the standard menu item?




Filibuster

Trigger Action when Standard Menu Item Selected?
 
Thanks, Ron - works just as I need - much appreciated...



All times are GMT +1. The time now is 02:39 PM.

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