AnsweredAssumed Answered

GetObject returning nothing in 2017

Question asked by Ryan Gerry on Jan 19, 2017
Latest reply on Apr 12, 2020 by Siddharth Salkar

After installing SW2017 'GetObject(, "Sldworks.Application")' started to return no value in an Excel to SW macro (VBA). I have tried 'swApp = GetObject(, "Sldworks.Application")' and 'Set swApp = Application.SldWorks' with the same results. This macro has been running successfully in a number of versions prior. Has anyone run into this? Has anyone resolved this?


Public Sub SW3dPoints1()

    Dim swApp As SldWorks.SldWorks

    Dim Part As SldWorks.ModelDoc2

    Dim Feat As SldWorks.Feature

    Dim i As Integer

    Dim count As Integer

    Dim mySketchPoint As SldWorks.SketchPoint

    Dim pxf As String

    Dim myNote As SldWorks.Note

    Dim Annotation As Object

    Dim pX, pY, pZ As Variant

    Dim pName As Variant

    Dim nmArr() As Variant

    Dim pat As String

    Dim conversion As Double

    Dim selmgr As SldWorks.SelectionMgr

    Dim ranges As Range, sName As Range

    Dim MessageBox As Integer

    Dim numSets As Integer

    Dim curSet As Integer

    Dim Fctr As Integer

    Dim didNm As Boolean

    Dim SkNmArr As Variant

    Dim sufX As String

    Dim ifExCt As Variant



MessageBox = MsgBox("Prerequisites: SolidWorks is running with a new Part Document open.  Sketches are closed.  A workbook containing X, Y, and Z coordinates to be plotted is open.  If desired, these points have a leftmost column containing their point name, which can be attatched as an annotation. " & vbCrLf & vbCrLf & "Press Cancel to stop and meet Prerequisites.", vbOKCancel)


If MessageBox = 2 Then

Exit Sub

End If




    On Error Resume Next


   ' Set swApp = CreateObject("SldWorks.Application")

   ' Set swApp = GetObject(, "Sldworks.Application")

    Set swApp = Application.SldWorks

    If swApp Is Nothing Then [this line is returns true]

    MsgBox "Macro could not find Solidworks Document.  Open Solidworks and rerun Macro." [Message is displayed]

    Exit Sub [Macro Ended]

    End If


...Code continues... [Macro is long and requires swAPP to be set]