PDA

View Full Version : Solved: User Form Properties Disappear



ffcgrant
09-26-2011, 09:19 AM
For some reason, the properties of my userform keep erasing. When I try to use the UserForm1.Show command I keep getting a "Run-time error '5852': Requested Object not available" I go to debug, and it highlights "Userform1.Show"

When I click on the userform under the Forms folder in VB editor, nothing appears in the properties window. When I click on the modules or Microsoft Word Objects, their properties appear just fine.

If I right click and select view object, I get an error message that says cannot perform operation. When I right click a second time and say show object, then it works and all of the information shows in the properties window. I save, exit, and go back in and again get the same issue.

I am using Word 2003. What can I do to fix this? I can't open the UserForm because of this error. I have attached a screenshot if that may be useful.

Thank you for the help!

Frosty
09-26-2011, 10:28 AM
You have option explicit on at the top of your module (which is a good thing). This requires variable declaration.


Sub Test
'create the variable
dim myForm as UserForm1

'create a new instance of the userform
Set myForm = New UserForm1

'Show it
myForm.Show

'do whatever you want from the form here

'empty the variable
set myForm = Nothing
End Sub

ffcgrant
09-26-2011, 10:55 AM
Thank you for your help Frosty, worked like a charm!