Help With Making A new Menu Bar

lhernandez

Active Member
Joined
May 22, 2006
Messages
282
I am using the following code to add a new menu bar to my workbook.
Code:
Sub BuildMenu()

Dim MenuBar As CommandBar
Dim Menu As CommandBarControl
Dim NMenu As CommandBarControl
Dim L1 As CommandBarControl
Dim L2 As CommandBarControl

On Error Resume Next
CommandBars("NewMenu").Delete
Set MenuBar = CommandBars.ActiveMenuBar
Set Menu = MenuBar.Controls("NewMenu")
MenuBar.Controls("NewMenu").Delete

Set NMenu = MenuBar.Controls.Add(Type:=msoControlPopup, temporary:=True, before:=10)
NMenu.Caption = "NewMenu"

Set L1 = NMenu.CommandBar.Controls.Add(Type:=msoControlButton, ID:=1)
With L1
    .Caption = "Run"
    .Style = msoButtonCaption
    .BeginGroup = True
    .OnAction = "Name of Macro"
End With

Set L1 = NMenu.CommandBar.Controls.Add(Type:=msoControlButton, ID:=1)
With L1
    .Caption = "Clear Active Sheet"
    .Style = msoButtonCaption
    .BeginGroup = True
    .OnAction = "Name of Macro"
End With

Set L1 = NMenu.CommandBar.Controls.Add(Type:=msoControlButton, ID:=1)
With L1
    .Caption = "Gather Info"
End With
    Set L2 = L1.CommandBar.Controls.Add(Type:=msoControlButton, ID:=1)
    With L2
        .Caption = "Schedule"
        .Style = msoButtonCaption
        .OnAction = "Name of Macro"
    End With
    
    Set L2 = L1.CommandBar.Controls.Add(Type:=msoControlButton, ID:=1)
    With L2
        .Caption = "Rates"
        .Style = msoButtonCaption
        .OnAction = "Name of Macro"
    End With

Can someone help me figure out why my L2 is not working? It is suppose to be a menu item with sub menus attached to it. Ex: on the main menu it will have a "gather info" option wich should create a sub menu to list "schedule" and "rates"
Any help would be great
thank you[/code]
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,136,597
Messages
5,676,719
Members
419,647
Latest member
usas12gthr

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