#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"