Changing the Excel Command Bar

Case250

Board Regular
Joined
Oct 4, 2006
Messages
54
Hi everyone.
I am trying to add a menu item to another menu item.


Example: I have added a menu called "Product" to the Worksheet command bar between the "Window" and "Help" menus. Within this new "Product" menu I have added a menu item called "Export" by doing as follows:

Set Item = CommandBars(1).Controls("Product").Controls.Add
Item.Caption = "&Export"
Item.OnAction = "ExportMacro"

Now I want to add additional menu items so that they appear or becom availiable when the user moves the hovers the mouse cursor over the "Export" menu item. To see what I am wanting to do; in Excel go "File" then "Print View". When you hover the cursor over "Print View" it reveals several other menu item options. How do I do this?
Thanks
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

DominicB

Well-known Member
Joined
Oct 3, 2005
Messages
1,569
Good afternoon Case250

Use something like this. I can't tailor this code any closer to your own project as you haven't posted the code you've used.

Code:
Sub Test()
Dim NewMenu As CommandBarPopup, MenuItem As CommandBarControl, Submenuitem As CommandBarButton
Set NewMenu = CommandBars(1).Controls.Add(Type:=msoControlPopup, temporary:=True)
NewMenu.Caption = "My Menu"
Set MenuItem = NewMenu.Controls.Add(Type:=msoControlPopup)
MenuItem.Caption = "My Menu Item"
Set Submenuitem = MenuItem.Controls.Add(Type:=msoControlButton)
Submenuitem.Caption = "My Sub Menu Item"
End Sub

HTH

DominicB
 

Forum statistics

Threads
1,136,263
Messages
5,674,710
Members
419,521
Latest member
Jasonnie

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
Top