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?
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
RE: Cannot SET Object! Run-time error '91' - Object not set
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