PDA

View Full Version : Using a button to open a userform trouble



zw1ck
02-28-2013, 04:10 PM
I'm trying to get a button in a word document to bring up a userform. Whenever I click the button I get the message variable not defined. Here is my code:
Private Sub CommandButton1_Click()
userform1.Show
End Sub
Any ideas :dunno

fumei
02-28-2013, 04:21 PM
Yes. The userform is not named userform1. Or....the userform is not available - perhaps it is not in the project.

Or...the procedure is not in a module that can find userform1.

zw1ck
02-28-2013, 04:26 PM
I checked, it is indeed called userform1, it is in the same project and should be available. the exact same code worked in excel. I retyped it and recreated the userform to avoid any issue with copying across different programs. My roommate had the same problem, figured it out but refuses to tell me. All he said was it was something stupid.

fumei
02-28-2013, 08:11 PM
"but refuses to tell me."

Really. While it is likely true that it is simple, pass this on to him..."You are a juvenile idiot. Grow up if you can."

It is something simple. It usually is. What module do you have the Sub in; or maybe try getting rid of Private.

So you are saying you recreated things (module, userform) and you CAN get .Show to work; then work backwards.