I am using the code below which creates top level and second level menu items. What I would like to do is add third level menu items to this.
Can anyone help
Code:Set cbSubMenu = cbMenu.Controls.Add(msoControlPopup, 1, , , True) With cbSubMenu .Caption = "&Import/Export" .Tag = "SubMenu1" .BeginGroup = True End With ' add menuitem to submenu With cbSubMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "&Import file" .OnAction = "get_file" .Style = msoButtonIconAndCaption .FaceId = 71 .State = msoButtonDown ' or msoButtonUp End With ' add menuitem to submenu With cbSubMenu.Controls.Add(msoControlButton, 1, , , True) .Caption = "&Export Data" .OnAction = "save_sheets_as_workbooks" .Style = msoButtonIconAndCaption .FaceId = 72 .Enabled = True ' End With
Hello tryer,
The third menu must be a CommandBarPopup. Refer to Visual Basic help files under CommandBarPopup. There is simply too much information to repeat it all here.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
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.
Hope it will help. Of course you can change FaceId if you want different icon, or Style or BeginGroup property, according to your needs.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
Bookmarks