ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting Menu Item by VBA Code (https://www.excelbanter.com/excel-programming/318343-selecting-menu-item-vba-code.html)

PosseJohn

Selecting Menu Item by VBA Code
 
I have an add-in which adds its own menu to the Excel program. I need to be
able to select a shortcut menu item by VBA to update the information
displayed on the worksheet. This will automate the update process for the
information (otherwise, will need to manually right-click and select the
menuitem ~20 times).

Thanx in advance.

Ron de Bruin

Selecting Menu Item by VBA Code
 
Hi

Application.CommandBars.FindControl(, 30010).Controls("&Google Search").Execute
This example will run a control on the Help menu for example

Post back with the name of your control and where it is if you need more help
For ID numbers see
http://www.rondebruin.com/menuid.htm



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


"PosseJohn" wrote in message ...
I have an add-in which adds its own menu to the Excel program. I need to be
able to select a shortcut menu item by VBA to update the information
displayed on the worksheet. This will automate the update process for the
information (otherwise, will need to manually right-click and select the
menuitem ~20 times).

Thanx in advance.




Bob Phillips[_6_]

Selecting Menu Item by VBA Code
 
John,

I would have thought that the best way was to set an object variable to the
men u item when creating it

Set myMenuItem =
Application.Commandbars("Standard").Controls.Add(T ype:=msoControlButton,temp
orary:=true)
myMenuItem.Caption = "abc"
etc.

Declare myMenuItem as a global object variable, and you can refer to that
anywhere in the code.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"PosseJohn" wrote in message
...
I have an add-in which adds its own menu to the Excel program. I need to

be
able to select a shortcut menu item by VBA to update the information
displayed on the worksheet. This will automate the update process for the
information (otherwise, will need to manually right-click and select the
menuitem ~20 times).

Thanx in advance.





All times are GMT +1. The time now is 05:15 PM.

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