How to find control button that was clicked inside submenu

156 Views Asked by At

I have menu with submenu made of control buttons:

Set MenuItem = .Controls.Add(Type:=msoControlPopup)
With MenuItem
    .caption = "Code Type"

    With .Controls.Add(Type:=msoControlButton)
        .caption = "Lists"
        .OnAction = "'" & ThisWorkbook.Name & "'!" & "setCaption"
    End With

End With

Sub setCaption()
    MsgBox Application.caller
End Sub

When I try with the above example, I get Type mismatch error.

0

There are 0 best solutions below