Access to model from Excel

Discussion in 'SolidWorks' started by fred, Dec 12, 2003.

  1. fred

    fred Guest

    Hi, I am trying to get access to the Sldworks model from Excel. The VBA code
    in Excel that I am using starts

    Dim swApp As Object, Part As Object

    Sub import()
    Set swApp = CreateObject("SldWorks.Application")
    Set Part = swApp.ActiveDoc

    If Part.GetType() = 3 Then 'swDocDRAWING Then
    ...

    This macro works fine on one PC here but not on my PC. We are both running
    XPP, SolidWorks 2004, Excel '97.
    The problem I am having is that the swApp.ActiveDoc always returns "nothing"
    and yet on the other PC it works fine.
    We both have "SldWorks 2004 Type Library" selected in the references in
    Excel.

    Has anyone got any ideas on what is wrong on my PC.

    Thanks
    Fred
     
    fred, Dec 12, 2003
    #1
  2. this *may* start a new, invisible SW session.
    Use GetObject(,"SldWorks.Application") instead to connect the running
    session (note the comma...)
     
    Philippe Guglielmetti, Dec 12, 2003
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.