lhernandez
Active Member
- Joined
- May 22, 2006
- Messages
- 282
I am using the following code to add a new menu bar to my workbook.
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]
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]