Assign an event handler

  • Thread starter Lisetsky Mykola
  • Start date
L

Lisetsky Mykola

Hello!
I'm using an Excel VBA and I'd like to assign an event handler to a
control. Something like this:

Button1.OnClick = ClickProc

Show me an example how to do this.
Thank you for your help.
 
C

Cindy M -WordMVP-

Hi Lisetsky,
I'm using an Excel VBA and I'd like to assign an event handler to a
control. Something like this:

Button1.OnClick = ClickProc
Double click on the control and VBA should create the event for you.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
L

Lisetsky Mykola

Cindy M -WordMVP- said:
Double click on the control and VBA should create the event for you.

I asked my question not clearly enough.
I create controls dynamically and want to assign event handlers dynamically
too.

Thanks for your advice.
 
C

Cindy M -WordMVP-

Hi Lisetsky,

Hmmm. I guess, theoretically this would be possible. It would require using
the VBExtensibility library. In an Excel VBA window
- set a Reference to the Microsoft Visual Basic for Applications
Extensibility 5.3 library

- type ThisWorkbook.VBProject.VBComponents then press F1 to get into the
VBE help.

- You can also use the Object Browser to get an overview of the object
model and access to the Help (look at CodeModule)

You'd have to write code into the same module where the procedure would be
written if you double-click the control.
I asked my question not clearly enough.
I create controls dynamically and want to assign event handlers dynamically
too.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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