Hi Guys,
I want to use one Function to trigger button action in the right-click menu conditioned by the button selected on the custom right-click menu.
The function that activates the right-click menu:
Const MyString As String ="MyMenuName"
Dim cbar As CommandBar
Dim bt as CommandBarButton
Set cbar = CommandBars.Add("MyMenuName", msoBarPopup,, False)
Set bt = cbar.Controls.Add
btCaption = "Button1"
bt.OnAction = "=DoSomething()"
bt.FaceId = 7468
bt.Tag = 1
btCaption = "Button2"
bt.OnAction = "=DoSomething()"
bt.FaceId = 7468
bt.Tag = 2
The Function "DoSomething()" should be used for both menu selections, and the activity should be determined by the "Tag".
Something like:
SelectCase bt.Tag
Case 1
action x
Case 2
action y
EndSelect
How should Function "DoSomething()" be designed?
Thanks!
I want to use one Function to trigger button action in the right-click menu conditioned by the button selected on the custom right-click menu.
The function that activates the right-click menu:
Const MyString As String ="MyMenuName"
Dim cbar As CommandBar
Dim bt as CommandBarButton
Set cbar = CommandBars.Add("MyMenuName", msoBarPopup,, False)
Set bt = cbar.Controls.Add
btCaption = "Button1"
bt.OnAction = "=DoSomething()"
bt.FaceId = 7468
bt.Tag = 1
btCaption = "Button2"
bt.OnAction = "=DoSomething()"
bt.FaceId = 7468
bt.Tag = 2
The Function "DoSomething()" should be used for both menu selections, and the activity should be determined by the "Tag".
Something like:
SelectCase bt.Tag
Case 1
action x
Case 2
action y
EndSelect
How should Function "DoSomething()" be designed?
Thanks!