How to refer to an ActiveX Control itself in event handler?

K

kf9150

Hello,

In the event handler function for a button, how do I refer to the
control itself? I tried "Me" but found out it refers to the active
worksheet.

I know I can get it by using ActiveSheet.OLEObjects("btn_RESET"), but
was wondering if there is an easier way.

Private Sub btn_RESET_Click()

End Sub

Thanks.
 
M

MichDenis

Try this,

'-------------------------------
Private Sub btn_RESET_Click()
Dim Btn As Object, Message As String
Set Btn = Shapes("CommandButton1").OLEFormat.Object.Object
Message = "Type of control : " & TypeName(Btn) & vbCrLf & _
"Caption : " & Btn.Caption
MsgBox Message
End Sub
'-------------------------------

<[email protected]> a écrit dans le message de groupe de discussion :
7670ae2f-024c-41c7-8baa-fcf94e2774fa@f20g2000prn.googlegroups.com...
Hello,

In the event handler function for a button, how do I refer to the
control itself? I tried "Me" but found out it refers to the active
worksheet.

I know I can get it by using ActiveSheet.OLEObjects("btn_RESET"), but
was wondering if there is an easier way.

Private Sub btn_RESET_Click()

End Sub

Thanks.
 
J

Jim Cone

Me.btn_RESET.Caption = "kf9150"
--
Jim Cone
Portland, Oregon USA




<[email protected]>
wrote in message
Hello,
In the event handler function for a button, how do I refer to the
control itself? I tried "Me" but found out it refers to the active
worksheet.
I know I can get it by using ActiveSheet.OLEObjects("btn_RESET"), but
was wondering if there is an easier way.

Private Sub btn_RESET_Click()

End Sub

Thanks.
 
Top