I have two different modules in my code. In module I create buttons and give them a tag so that I know which buttons that has been pressed. When a button is pressed the .onAction runs and calls a sub. in that sub i want to check which button that was in fact pressed by checking the tag. however i do not know how to write the code for that when the tag is assigned in a different module. Please help me with this code! My code in the module where I create the buttons is:
Sub Create_Menu()
Dim stapelDiagramKnapp As CommandBarButton
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Tag = "stapel"
.BeginGroup = True
.OnAction = "ChartModul1.arrayLoop"
end with
and in the sub in the module ChartModul1:
Sub arrayLoop()
Dim cmdBtn As CommandBarButton
Set cmdBtn = Meny.CommandBars.ActionControl
If cmdBtn.Tag = "stapel" Then
MsgBox ("Tag = stapel")
End If
I guess I have it wrong on the Set cmdBth line but I do not know how to write it. Please help me! Thanks very much!
Sub Create_Menu()
Dim stapelDiagramKnapp As CommandBarButton
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Tag = "stapel"
.BeginGroup = True
.OnAction = "ChartModul1.arrayLoop"
end with
and in the sub in the module ChartModul1:
Sub arrayLoop()
Dim cmdBtn As CommandBarButton
Set cmdBtn = Meny.CommandBars.ActionControl
If cmdBtn.Tag = "stapel" Then
MsgBox ("Tag = stapel")
End If
I guess I have it wrong on the Set cmdBth line but I do not know how to write it. Please help me! Thanks very much!