View Single Post
  #3  
Old 07-05-2009, 04:36 AM
buran buran is offline
Forum Contributor
 
Join Date: 25 Jun 2009
Location: Sofia, Bulgaria
MS Office Version:Excel 2003, Excel 2007
Posts: 116
buran has an addiction to Excel
Re: Adding sub menu's

Here is an example from an add-in, I have made. Here I add MyMenu1 as a second level menu to MyMenu (in your case that's cbMenu). After that I add two buttons to this sub-menu. When you add msoControlButton for all the macros you want, you start adding msoControlButton again to the top level menu.

Code:
Set MyMenu1 = MyMenu.Controls.Add _
                  (Type:=msoControlPopup, Temporary:=True)
    MyMenu1.Caption = "Caption" 'Your caption here
    MyMenu1.BeginGroup = True


    Set newBtn = MyMenu1.Controls.Add(Type:=msoControlButton)
    With newBtn
        .Caption = "Caption1" 'Your caption here
        .FaceId = 230
        .Style = msoButtonIconAndCaption
        .OnAction = "Macro1" 'Your macro name here
    End With


    Set newBtn = MyMenu1.Controls.Add(Type:=msoControlButton)
    With newBtn
        .Caption = "Caption2" 'Your caption here
        .FaceId = 2019
        .Style = msoButtonIconAndCaption
        .OnAction = "Macro2" 'Your macro name here
    End With
Hope it will help. Of course you can change FaceId if you want different icon, or Style or BeginGroup property, according to your needs.
Reply With Quote