0

I feel like this should be a really simple problem but I can't seem to find an answer to it anywhere. How to I find a reference to the object currently executing vba code? For example, I made a blank workbook, and in sheet1 placed a command button. I then added the following code

Private Sub CommandButton1_Click()

Dim objtest As Object
Set objtest = Me

Debug.Print objtest.Name

End Sub

The result is "sheet1" when I would like it to be "CommandButton1" how do I get the object reference to commandbutton1?

edit: Thank you, the application.caller property seems like a great solution (although it is currently throwing an error, but that's not really important.) The problem is the application I actually want to write this code in is IFIX graphics package. I assumed the VBA calls would be the same for VBA in all applications, but this one does not appear to recognize the application.caller property. Does anyone happen to know IFIX specifically, or maybe a way to import this method, etc.?

0 Answers0