I am trying to make some things happen when my user form loads in Word 2002.
I have tried FormName_Load and FormName_Initialize, but neither seem to
produce the effect desired. For example, consider a userform that you bring
up, and at initialization you want it to make some checks and based on these
render certain controls non visible. This is what I am trying to do. Thanks
for your help.
Tony Jollans - 25 Oct 2005 01:13 GMT
The Events (to go in the userform's class module are UserForm_Initialize
(and perhaps UserForm_Activate depending on what you want to do) - that is
"UserForm", not the Userform Name. If you're unsure of events you can select
them via the dropdowns at the top of the code window.
--
Enjoy,
Tony
> I am trying to make some things happen when my user form loads in Word 2002.
> I have tried FormName_Load and FormName_Initialize, but neither seem to
> produce the effect desired. For example, consider a userform that you bring
> up, and at initialization you want it to make some checks and based on these
> render certain controls non visible. This is what I am trying to do. Thanks
> for your help.
Jay Freedman - 25 Oct 2005 01:15 GMT
>I am trying to make some things happen when my user form loads in Word 2002.
>I have tried FormName_Load and FormName_Initialize, but neither seem to
>produce the effect desired. For example, consider a userform that you bring
>up, and at initialization you want it to make some checks and based on these
>render certain controls non visible. This is what I am trying to do. Thanks
>for your help.
There are two event procedures that fire when a userform's .Show
method is called.
The first one is named UserForm_Initialize. (It doesn't contain the
actual name of the userform, but the constant string "UserForm".) This
event occurs before the dialog box appears on screen.
The second one is named UserForm_Activate, and it occurs every time
the dialog appears on the screen. If a control on the userform calls
Me.Hide and then other code calls the .Show method again before the
userform is unloaded, UserForm_Activate will fire again.
The UserForm_Initialize event is the one you usually want. For some
purposes either event will do equally well. You must use the _Activate
event for things that have to be reinitialized for each reappearance.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org