×
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

Since installing 2006 some macros don't work.

Since installing 2006 some macros don't work.

Since installing 2006 some macros don't work.

(OP)
Since installing 2006 some macros don't work. I stepped through and the
problems start right here:

   Set swApp = CreateObject("SldWorks.Application")

When I step past this line swApp = nothing.

TIA

www.engtran.com
www.niswug.org

RE: Since installing 2006 some macros don't work.

I don't know anything about this, but I thought I saw something along these lines in a post a while back.  Something to the effect that you have to update your folder/application/whatever location so SW can find what you're looking for.  From SW 05 to SW 06.

Perhaps you'll get the gist of it from this post.  Otherwise, someone who does this stuff can point you more specifically.

Jeff Mowry
www.industrialdesignhaus.com
Reason trumps all.  And awe trumps reason.

RE: Since installing 2006 some macros don't work.

In fact, this may have been a registry redirect.  Do a search and maybe you'll turn something up.

Did you use a version-specific folder such as "SolidWorks2006" and "SolidWorksData2006" when installing?  Do you still have SW 2005 installed without being installed in a specific directory?  If not, this could be causing the problem that requires the redirect.

Jeff Mowry
www.industrialdesignhaus.com
Reason trumps all.  And awe trumps reason.

RE: Since installing 2006 some macros don't work.

I believe the preferred method for obtaining the SldWorks object has been changed, assuming you are running this macro from inside SolidWorks and not attaching to SolidWorks from some external app (Excel, some VB program, etc).

Try replacing:

   Set swApp = CreateObject("SldWorks.Application")

with:

   Set swApp = Application.Sldworks

and see if that helps.

RE: Since installing 2006 some macros don't work.

(OP)
Thanks, it now works. I searched through the API help and examples and found nothing on this. Where did you find this?

www.engtran.com
www.niswug.org

RE: Since installing 2006 some macros don't work.

You can sort-of find the documentation by opening the API help, typing "Applications" into the index, and double-clicking on "standalone".  I believe the Application.SldWorks method has been around since '01 or '03.  When I first started writing macros all of the examples I had used CreateObject, but I noticed that any time you record a new one or start one from scratch SolidWorks automatically puts in the Application.SldWorks code.  I believe I had some trouble myself with an old macro I was trying to modify that was solved by using Application.Sldworks instead of CreateObject, so I've used it ever since.  If you're writing a VB6 application you have to use CreateObject.  I'm guessing you'd need to use CreateObject to attach to SW from another VBA macro as well.

RE: Since installing 2006 some macros don't work.

(OP)
CreateObject is in so many of SW examples. Whew. Have a good holiday.

www.engtran.com
www.niswug.org

RE: Since installing 2006 some macros don't work.

Very true.  I don't think they update the examples in the help file with each release.  There are a lot of objects/methods etc. that get new versions with later releases.  For backward compatibility, the new version just gets a number tacked on the end.  Take SelectionMgr::GetSelectedObjectType.  It's up to GetSelectedObjectType6 by now!  Since the old methods still work, they don't update the help file examples.  

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