Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA won't recognize form object

I am working on a new project and have created a form
which VBA named UserForm1. It appears in the object list
for VBAProject. The line
UserForm1.Show
was being executed before, but now repeatedly gives me
a 'Need Object' error.

I can't seem to get VBA to recognize the form. Any
suggestions would be gratefully received.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default VBA won't recognize form object

Sometimes the debugger don't display the actual arror, just its caller, or its callers
caller, or its callers callers caller. Or its ...

UserForm1.Show
is good enough (unless you renamed the userform something else than UserForm1). So it must
be something it the userform's Initialize or Activate code that is either wrong or calling
something wrong. Or calling something that's calling something wrong. Or ...

Those things take time to spot. It's just the way it is.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Hilde" wrote in message
...
I am working on a new project and have created a form
which VBA named UserForm1. It appears in the object list
for VBAProject. The line
UserForm1.Show
was being executed before, but now repeatedly gives me
a 'Need Object' error.

I can't seem to get VBA to recognize the form. Any
suggestions would be gratefully received.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default VBA won't recognize form object

have you Dim'd a variable named Userform1 elsewhere in your code?

For instance

Dim Userform1 As Object
Userform1.Show

will fail since you've not set the variable UserForm1 to an object that
can be shown.

Note that some will argue that even though VBA allows it, it's not
proper technique to instantiate an object using the class name. Instead,
"proper" technique is to declare an object variable of the class, then
set the variable to a new instance of the object, so instead of

Public MySub()
UserForm1.Show
End Sub

you'd use

Public MySub()
Dim myForm As UserForm1
Set myForm = New UserForm1
myForm.Show
End Sub

using the second method, you can create multiple form object variables,
all of which can be set at the same time.


In article ,
"Hilde" wrote:

I am working on a new project and have created a form
which VBA named UserForm1. It appears in the object list
for VBAProject. The line
UserForm1.Show
was being executed before, but now repeatedly gives me
a 'Need Object' error.

I can't seem to get VBA to recognize the form. Any
suggestions would be gratefully received.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA won't recognize form object


Thanks. You are absolutely right -- it takes time (about 3 hours) but I
did track the error down in the initialization procedure. Nice of you
to reply.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #5   Report Post  
Posted to microsoft.public.excel.programming
lol lol is offline
external usenet poster
 
Posts: 1
Default VBA won't recognize form object

Thanks for the input. I found the problem in the Initialization
procedure. I appreciate the reminder of good programming procedure,
however, and will do it!

lol

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Label Options - Forms Object vs Control Box Object Awrex Excel Discussion (Misc queries) 3 July 17th 09 07:10 PM
Form Letter and Embeded Word Object Aaron Excel Discussion (Misc queries) 2 July 15th 06 01:22 AM
How do I resize a check box form object in Excel? bpoole Excel Discussion (Misc queries) 1 May 11th 06 06:38 PM
Multipage Object on User Form Paul Cheers Excel Programming 2 November 27th 03 11:40 AM
Using a string to point to a form object? plumbye Excel Programming 1 September 8th 03 06:49 PM


All times are GMT +1. The time now is 07:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"