What event occurs on form load?

J

JFW

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.
 
T

Tony Jollans

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.
 
J

Jay Freedman

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.
 

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