How to get the clicked ActiveX control itself in its click event?

天成 王 0 Reputation points
2023-03-14T08:53:43.4766667+00:00

I used the keyword "Me", but I got the sheet where the ActiveX control is located instead of the control itself.

Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Excel | For business | Windows
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 122.6K Reputation points
    2023-03-14T10:12:56.8666667+00:00

    I think that the ActiveX control should have a name. For example, if you insert a textbox, then its name is TextBox1, which can be seen or changed in Name Box field of Excel. You can also enable the Design Mode, select the ActiveX and press the Properties button from Developer tab. Then you can edit the name.

    To access the control, use its name, for example: text = TextBox1.Text.

    Show some details if your case is different.


  2. Olaf Helper 47,516 Reputation points
    2023-03-14T10:20:28.6266667+00:00

    The event is bound to the control, so within the event code you know which control was clicked.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.