Jaafar Tribak
Well-known Member
- Joined
- Dec 5, 2002
- Messages
- 9,806
- Office Version
- 2016
- Platform
- Windows
Hi,
Say for example, you have a couple of modeless userforms on display and you want to run some small macro each time you activate each userform.
The obvious answer is simply placing the small macro (or a call to it) in each of the
But what If you wanted to have a common event handler in a class module that runs the common code (similar to what we do with form controls) ?
If you try using
Yes. I have come up with some workarounds like subclassing the userforms ( and catching the WM_NCACTIVATE ) or using a windows timer to detect when the userforms are being activated but I am trying to avoid such approaches as they are both risky and have a heavy performance hit. I am looking for a more OOP oriented approach.
Does anyone have any suggestions ?
The subject of this recent thread is what prompted me to post this question.
Say for example, you have a couple of modeless userforms on display and you want to run some small macro each time you activate each userform.
The obvious answer is simply placing the small macro (or a call to it) in each of the
UserForm_Activate
event handlers.But what If you wanted to have a common event handler in a class module that runs the common code (similar to what we do with form controls) ?
If you try using
Private WithEvents uFormEVents As UserForm
, you will find that the Actiavate\Deactivate events are not exposed by the class.Yes. I have come up with some workarounds like subclassing the userforms ( and catching the WM_NCACTIVATE ) or using a windows timer to detect when the userforms are being activated but I am trying to avoid such approaches as they are both risky and have a heavy performance hit. I am looking for a more OOP oriented approach.
Does anyone have any suggestions ?
The subject of this recent thread is what prompted me to post this question.