Adding Popup Button to Main Menu Bar

Premanshu

Board Regular
Joined
Oct 2, 2007
Messages
91
Hi,

I have made some macro and now want to add a Popup button for it in the Main Menu bar.
I tried below code, but this is not working.

Set cbMainMenuBar = Application.CommandBars("Worksheet Menu Bar").Controls("Tools")

Set cbcCutomMenu = cbMainMenuBar.Controls.Add(Type:=msoControlPopup, Before:=5)
cbcCutomMenu.Caption = "My_Macro"


though when i am trying to add a Popup button directly to Main Menu bar that's working with below code.

Set cbMainMenuBar = Application.CommandBars("Worksheet Menu Bar")

Set cbcCutomMenu = cbMainMenuBar.Controls.Add(Type:=msoControlPopup, Before:=5)
cbcCutomMenu.Caption = "My_Macro"


can anyone suggest me how can I add My_Macro button to the Tools Menu in Main Menu Bar.


Regards
Premanshu.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
What exactly do you mean when you say it's not working?
 
Upvote 0
when i run the macro a button should get added to the Tools menu in the Main Menu Bar like other button which already exist (i.e Share Workbook, Protection, Formula Auditing....etc)

but this is not happening after running the macro.
 
Upvote 0
It works for me - are you getting an error?
 
Upvote 0
ok this time i got it....
i had incorrectly defined the variable....
sorry for the unnecessary trouble...
and thank you So much :)>


Regards
Premanshu.
 
Upvote 0

Forum statistics

Threads
1,206,710
Messages
6,074,457
Members
446,071
Latest member
Jolon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top