How to read event definitions behind ActiveX controls with VBA code?

Thomko

Registered User.
Local time
Today, 12:23
Joined
Jul 15, 2008
Messages
50
Here the scenario:

I want to analyze forms via VBA code and see which controls have events behind them and of what type they are (Event Procedure, Macro or Expression).

Now the problem:

I have code for the standard controls like Text Boxes, Option Buttons etc. that works fine.

Code:
EventDefinition = Control.Properties("<Name of Event>")
or a bit more real life:
Code:
sEventDefinition = MyForm!txtTextBox.Properties("OnDblClick")
This throws (a catchable) run time error if the event does not exist for the control in question. If it exists, sEventDefinition will contain an empty string, the Expression, the Macro name or the term "[Event Procedure]". This way I can find out in VBA code if a theoretically possible event is in use for that control and what it does.

The approach above does only partially work for ActiveX controls like Tree Views. Some Events (like OnClick, OnKeyPress etc.) cannot be read that way. They are also not detectable by enumerating the control properties (only five events commmon to all ActiveX controls are listed, but not all).

So I am looking for VBA code that can read ALL event definitions of ActiveX controls.

Anyone, any thoughts?
Thomas
 
Hello Tony,

thank you for your reply. As you point out in your video, there are five events easily accessible that are common to all ActiveX components (OnEnter, OnExit, OnGotFocus, OnLostFocus, OnUpdated) but the others are not. I tried all variations of your tip (class wrapper) I could think of but to no avail. Googling up and down the Internet brought also no solutions :-(( .
Do you remember where you saw it? A forum, a news group, a book? Can you recommend google terms that might bring up the source that you have in mind (maybe after some digging)?

I start considering ugly workarounds, but there MUST be a solution. The IDE also knows, what events are available and in use ...
 
Hello Tony,

thank you very much for the info. I now have another idea or two how it may work. I will need to study more (and learn more about the inside of activex controls). Your links will be a great help. E.g this snippet from one of the pages sounds promising:

IProvideClassInfo2 Provides quick access to an object's Interface ID (IID) for its event set. An extension to IProvideClassInfo.

Seems that some low-level programming is required. Yeah, looks like fun :-)

I will let you know if I finally find a way. If you stumble over some related material in the near future please do not hesitate to post also that in this thread. This is nagging me for months and I would be surprised if I find a quick solution.

Bye for now
Thomas
 

Users who are viewing this thread

Back
Top Bottom