×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Cannot SET Object! Run-time error '91' - Object not set

Cannot SET Object! Run-time error '91' - Object not set

Cannot SET Object! Run-time error '91' - Object not set

(OP)
Help! My code was working fine yesterday, I'm not sure what happened.  I have an object swChildComp, declared as

Dim swChildComp                 As SldWorks.Component2

-- which works fine, because I can extract a part name from it

strModName = swChildComp.Name

--but when I try to set another object, declared as

Dim Part                        As Object

--then set like this:

Set Part = swChildComp.GetModelDoc

-- it remains as 'Nothing'

what gives?  Like I said, it was working before, then it broke.  The only (possible) significance I noticed is that when it was working, I had another macro still loaded in SW VBA.  I think it may have stopped working when I finally closed SW and unloaded the other macro. The 2 macros were destined to become one anyway, so I figured I could work around the issue by going ahead and merging the two.  So I did, but nothing changed.
What could be going on? Any ideas at all?  

RE: Cannot SET Object! Run-time error '91' - Object not set

Why are you delcaring Part as Object rather than SldWorks.ModelDoc2?  That could help.  Also, according to API help, if the component is either suppressed or lightweight then the GetModelDoc call will return Null.

RE: Cannot SET Object! Run-time error '91' - Object not set

(OP)
handleman,

I took your advice, and it worked!  I also moved that line of code to follow

If (False = swChildComp.IsSuppressed) And (False = swChildComp.ExcludeFromBOM) Then

to check for suppressed components.  *DOH!*

Thanks again handleman, The Tecumseh Group should put you on their salary!

RE: Cannot SET Object! Run-time error '91' - Object not set

He is ... trouble is their currency is little purple stars.

cheers

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources