5 Replies Latest reply on Jul 30, 2013 11:31 AM by Evan Dlugopolski

    Help with code debuging for inserting part doc into assembly

    Evan Dlugopolski

      Hello everyone,

       

      I cant figure out what is wrong with this code:

      ---------------

              Dim openDocs As Object
              Dim swPartDoc As PartDoc
              Dim swAssemblyDoc As AssemblyDoc
              Dim currentModel As ModelDoc2
              Dim partFileName As String

            

            * openDocs = swApp.GetDocuments()

              For Each currentModel In openDocs
                  If (currentModel.GetType = swDocumentTypes_e.swDocASSEMBLY) Then
                      swAssemblyDoc = currentModel
                  End If
                 
                  If (currentModel.GetType = swDocumentTypes_e.swDocPART) Then
                      swPartDoc = currentModel
                      partFileName = swPartDoc.GetPathName()
                  End If
              Next


              bool = swAssemblyDoc.AddComponent4(partFileName, "Default", 0#, 0#, 0#)


              swApp.CloseDoc (partFileName)

      --------------------

      get error "saying object variable or with block variable not set" at the line marked (*).

       

      Any help would be much appreciated