PDA

View Full Version : UserForm.show run-time error 76



truszko1
05-26-2011, 08:35 AM
Hey, guys. I am working on a module in the Office Word 2010. In the Normal Project I have created a userform, called UserForm3. In my Module, one of the lines is supposed to show the userform, so I typed in UserForm3.Show, but I get the "Path not found" error. Before the main sub, I have created a few global variables. When I remove all of the code for the global variables, the UserForm3.Show works perfectly fine. Why is that?

macropod
05-27-2011, 04:35 AM
Hi truszko1,

Without seeing the code, no specific advice can be given.

Frosty
05-31-2011, 02:38 PM
Yes, a bit generic to give specific advice about your code. Also, don't forget to mark your other thread as solved when someone solves it.

Here is some generic advice:

1. Don't leave generic names for your forms... name them something appropriate (and use prefixes)... so UserForm3 should be renamed to something like frmMyAppropriatelyNamedUserForm

2. Don't use "UserForm3.Show" type coding. Always use something like
dim f as New UserForm3
f.Show

OR

dim f as UserForm3
Set f = New UserForm3
f.Show

I prefer the second scenario, but there are arguments for either. However, to explain why to use one of those two (rather than what you used) would require a bit of a discussion about variable scope, which I imagine would make your eyes glaze.

3. Be careful with rampant usage of global variables. It can be hell to track down problems in your code (which is one of the reasons why, I suspect, it is tough to respond to Paul's request to show us the code-- because your code is far from encapsulated). Simply getting rid of your global variables and using my suggestion in #2 would probably make whatever problem you're having so obvious that you wouldn't need anyone's help.

4. If you want to skip all of the above... check your _Activate and _Initialize events in UserForm3. Put breakpoints on them. Run your code... when it breaks, use F8 to step through the code. My guess is that you're initializing UserForm3 well before you think you are in your code, and that multiple instances are getting created. But that's just a guess.