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 :
(e-mail address removed)...
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top