I have the following code that builds a custom menu in Excel. Works well. I'm trying to modify it to use sub menus. It will add the menu item for East Options and West Options. I'm trying to modify the East and West # 1 items so they appear as a sub menu. I've tried a number of different things but I haven't got the syntax right. Any help would be appreciated. Thanks.........
Dim cbWsMenuBar As CommandBar
Dim TrCustom As CommandBarControl
Dim iHelpIndex As Long
Dim vFoundMenu As Boolean
Set cbWsMenuBar = Application.CommandBars("Worksheet Menu Bar")
cbWsMenuBar.Visible = True
Dim CCnt As Long
For CCnt = 1 To cbWsMenuBar.Controls.Count
If InStr(1, cbWsMenuBar.Controls(CCnt).Caption, "Translate") > 0 Then vFoundMenu = True
Next CCnt
If vFoundMenu = False Then
Set TrCustom = cbWsMenuBar.Controls.Add(Type:=msoControlPopup) ', before:=iHelpIndex)
With TrCustom
.Caption = "Menu Items”
With .Controls.Add(Type:=msoControlButton)
.Caption = "Business Unit to Group"
.OnAction = "ShowBU2GP"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Group to Business Unit"
.OnAction = "ShowGP2BU"
End With
With .Controls.Add(Type:=msoControlPopup)
.Caption = "East Region Options"
End With
‘ EAST # 1
' With .Controls.Add(Type:=msoControlButton)
' .Caption = "East Branch to DeptID"
' .OnAction = "ShowEastDeptID"
' .BeginGroup = True
' End With
With .Controls.Add(Type:=msoControlPopup)
.Caption = "West Options"
End With
' WEST # 1
' With .Controls.Add(Type:=msoControlButton)
' .Caption = "West Branch to DeptID"
' .OnAction = "ShowWestDeptID"
' .BeginGroup = True
' End With
End With
End If
I will show you a very simple example. Please amend it to suit your needs :)
Screenshot