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.
MsgBox TypeName(Application.Caller)give you?MsgBox TypeOf Application.Caller Is Objectreturn true? The idea is to get what type the caller is, IIRC should be aCommandBarButton. Alternatively you could take a string parameter and pass it along in theOnActionstring, that would be more reliable than Application.Caller IMO.MsgBox TypeOf Application.Caller Is Objectgives False