K
Kent Prokopy
I have the following code.
Private Sub Workbook_Open()
' Add menu item for Finops.
With Application.CommandBars("WorkSheet Menu
Bar").Controls.Add(Type:=msoControlPopup)
.Caption = "MyMenu"
' Add menu items for showing and hiding groups of sheets.
With .Controls.Add(msoControlPopup, 1)
.BeginGroup = True
.Caption = "Options"
' Sub Menus.
With .Controls.Add(msoControlButton, 1)
.Caption = "Option1"
.Tag = 0
.OnAction = "modMain.DoSomeThing"
End With
With .Controls.Add(msoControlButton, 1)
.Caption = "Option2"
.Tag = 1
.OnAction = "modMain.DoSomeThing"
End With
End With
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("WorkSheet Menu Bar").Controls("MyMenu").Delete
End Sub
When I select "Option1" or "Option2" from my custom menu and the Sub
DoSomeThing is executed. I need to know what sub menu called it/was clicked.
Both sub menus call the same Sub.
Private Sub Workbook_Open()
' Add menu item for Finops.
With Application.CommandBars("WorkSheet Menu
Bar").Controls.Add(Type:=msoControlPopup)
.Caption = "MyMenu"
' Add menu items for showing and hiding groups of sheets.
With .Controls.Add(msoControlPopup, 1)
.BeginGroup = True
.Caption = "Options"
' Sub Menus.
With .Controls.Add(msoControlButton, 1)
.Caption = "Option1"
.Tag = 0
.OnAction = "modMain.DoSomeThing"
End With
With .Controls.Add(msoControlButton, 1)
.Caption = "Option2"
.Tag = 1
.OnAction = "modMain.DoSomeThing"
End With
End With
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("WorkSheet Menu Bar").Controls("MyMenu").Delete
End Sub
When I select "Option1" or "Option2" from my custom menu and the Sub
DoSomeThing is executed. I need to know what sub menu called it/was clicked.
Both sub menus call the same Sub.