Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sub menuing
I have added a "NewMenuItem" to the main commandbar. Below that I have added
two SubMenuItems with no assigned OnAction events. Set Item = CommandBars(1).Controls("NewMenuItem").Controls.Ad d Item.Caption = "&SubItem1" Item.BeginGroup = False Set Item = CommandBars(1).Controls("NewMenuItem").Controls.Ad d Item.Caption = "&SubItem2" Item.BeginGroup = False What I want to do is be able to select the "SubItem1" and create multiple menu items below it. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sub menuing
You want to do this in the same code that creates the SubItems or do you want
code to run when you select the created subitem? -- Regards, Tom Ogilvy "Troubled User" wrote: I have added a "NewMenuItem" to the main commandbar. Below that I have added two SubMenuItems with no assigned OnAction events. Set Item = CommandBars(1).Controls("NewMenuItem").Controls.Ad d Item.Caption = "&SubItem1" Item.BeginGroup = False Set Item = CommandBars(1).Controls("NewMenuItem").Controls.Ad d Item.Caption = "&SubItem2" Item.BeginGroup = False What I want to do is be able to select the "SubItem1" and create multiple menu items below it. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sub menuing
Just in the same code, after the SubItem is created. Thanks.
"Tom Ogilvy" wrote: You want to do this in the same code that creates the SubItems or do you want code to run when you select the created subitem? -- Regards, Tom Ogilvy "Troubled User" wrote: I have added a "NewMenuItem" to the main commandbar. Below that I have added two SubMenuItems with no assigned OnAction events. Set Item = CommandBars(1).Controls("NewMenuItem").Controls.Ad d Item.Caption = "&SubItem1" Item.BeginGroup = False Set Item = CommandBars(1).Controls("NewMenuItem").Controls.Ad d Item.Caption = "&SubItem2" Item.BeginGroup = False What I want to do is be able to select the "SubItem1" and create multiple menu items below it. Thanks. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sub menuing
Sub ABC()
Dim Menu1 As CommandBarPopup Dim Item1 As CommandBarPopup Dim Item2 As CommandBarPopup Dim Item1Sub1 As CommandBarButton Dim Item1Sub2 As CommandBarButton Dim Item2Sub1 As CommandBarButton Dim Item2Sub2 As CommandBarButton On Error Resume Next CommandBars(1).Controls("NewMenuItem").Delete On Error GoTo 0 Set Menu1 = CommandBars(1).Controls.Add(Type:=msoControlPopup) Menu1.Caption = "NewMenuItem" Set Item1 = CommandBars(1).Controls("NewMenuItem" _ ).Controls.Add(Type:=msoControlPopup) Item1.Caption = "&SubItem1" Item1.BeginGroup = False Set Item2 = CommandBars(1).Controls("NewMenuItem" _ ).Controls.Add(Type:=msoControlPopup) Item2.Caption = "&SubItem2" Item2.BeginGroup = False Set Item1Sub1 = Item1.Controls.Add(Type:=msoControlButton) Set Item1Sub2 = Item1.Controls.Add(Type:=msoControlButton) Set Item2Sub1 = Item2.Controls.Add(Type:=msoControlButton) Set Item2Sub2 = Item2.Controls.Add(Type:=msoControlButton) Item1Sub1.Caption = "Item1Sub1" Item1Sub2.Caption = "Item1Sub2" Item2Sub1.Caption = "Item2Sub1" Item2Sub2.Caption = "Item2Sub2" End Sub I just set the caption attributes, but you can add other attributes/onaction. -- Regards, Tom Ogilvy "Troubled User" wrote: Just in the same code, after the SubItem is created. Thanks. "Tom Ogilvy" wrote: You want to do this in the same code that creates the SubItems or do you want code to run when you select the created subitem? -- Regards, Tom Ogilvy "Troubled User" wrote: I have added a "NewMenuItem" to the main commandbar. Below that I have added two SubMenuItems with no assigned OnAction events. Set Item = CommandBars(1).Controls("NewMenuItem").Controls.Ad d Item.Caption = "&SubItem1" Item.BeginGroup = False Set Item = CommandBars(1).Controls("NewMenuItem").Controls.Ad d Item.Caption = "&SubItem2" Item.BeginGroup = False What I want to do is be able to select the "SubItem1" and create multiple menu items below it. Thanks. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sub menuing
Thank you. Just what I wanted!
"Tom Ogilvy" wrote: Sub ABC() Dim Menu1 As CommandBarPopup Dim Item1 As CommandBarPopup Dim Item2 As CommandBarPopup Dim Item1Sub1 As CommandBarButton Dim Item1Sub2 As CommandBarButton Dim Item2Sub1 As CommandBarButton Dim Item2Sub2 As CommandBarButton On Error Resume Next CommandBars(1).Controls("NewMenuItem").Delete On Error GoTo 0 Set Menu1 = CommandBars(1).Controls.Add(Type:=msoControlPopup) Menu1.Caption = "NewMenuItem" Set Item1 = CommandBars(1).Controls("NewMenuItem" _ ).Controls.Add(Type:=msoControlPopup) Item1.Caption = "&SubItem1" Item1.BeginGroup = False Set Item2 = CommandBars(1).Controls("NewMenuItem" _ ).Controls.Add(Type:=msoControlPopup) Item2.Caption = "&SubItem2" Item2.BeginGroup = False Set Item1Sub1 = Item1.Controls.Add(Type:=msoControlButton) Set Item1Sub2 = Item1.Controls.Add(Type:=msoControlButton) Set Item2Sub1 = Item2.Controls.Add(Type:=msoControlButton) Set Item2Sub2 = Item2.Controls.Add(Type:=msoControlButton) Item1Sub1.Caption = "Item1Sub1" Item1Sub2.Caption = "Item1Sub2" Item2Sub1.Caption = "Item2Sub1" Item2Sub2.Caption = "Item2Sub2" End Sub I just set the caption attributes, but you can add other attributes/onaction. -- Regards, Tom Ogilvy "Troubled User" wrote: Just in the same code, after the SubItem is created. Thanks. "Tom Ogilvy" wrote: You want to do this in the same code that creates the SubItems or do you want code to run when you select the created subitem? -- Regards, Tom Ogilvy "Troubled User" wrote: I have added a "NewMenuItem" to the main commandbar. Below that I have added two SubMenuItems with no assigned OnAction events. Set Item = CommandBars(1).Controls("NewMenuItem").Controls.Ad d Item.Caption = "&SubItem1" Item.BeginGroup = False Set Item = CommandBars(1).Controls("NewMenuItem").Controls.Ad d Item.Caption = "&SubItem2" Item.BeginGroup = False What I want to do is be able to select the "SubItem1" and create multiple menu items below it. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|