3 Replies Latest reply on Jan 10, 2017 7:34 AM by Deepak Gupta

    Object library feature not supported - 2016 SP5

    Mathew Challinor

      hi,

       

      I had a macro that was running fine until we have just changed to 2016 SP5, when I debug the macro I get the error Object library feature not supported.

       

      Sub Main()
       
          Dim swApp               As SldWorks.SldWorks
          Dim swModel             As ModelDoc2
          Dim swDraw              As DrawingDoc
          Dim longstatus          As Long, longwarnings As Long
          Dim FilePath            As String
          Dim PDFpath             As String
          Dim PathSize            As String
          Dim dwgname          As String
          Dim dwgFilePath     As String


          Set swApp = Application.SldWorks
          Set swModel = swApp.ActiveDoc
         
              'Check if a file is open
          If swModel Is Nothing Then
              MsgBox ("Please open a Tooling Assembly Drawing and Re Run the macro.")
              Exit Sub
          End If
         
          'Check if a drawing is open
          If Not swModel.GetType = swDocDRAWING Then
              MsgBox ("Please open a Tooling Assembly Drawing and Re Run the macro.")
              Exit Sub
          End If
             
             
             
      'Get PDF name
          
           FilePath = swModel.GetTitle
           PathSize = Strings.Len(FilePath)
           dwgname = Strings.Left(FilePath, PathSize - 16)
         
         
      'Check if PDF is already open

          If IsFileOpen("P:\Tooling Assemblies\Tooling Assembly Drawings\TA-1001.pdf") Then
              ' if file open, user message stating the file in use.
              MsgBox dwgname & ".pdf" & " is already opened" & vbCr & " File cannot be saved" & "Close Tool Assembly Data Base and Re Run Macro"
              Exit Sub

          Else
         
               PDFpath = "P:\Tooling Assemblies\Tooling Assembly Drawings\" & dwgname & ".pdf"
               longstatus = swModel.SaveAs3(PDFpath, 0, 0)
              
          End If
         
          'Save Drawing
          Set swModel = swApp.ActiveDoc
          dwgFilePath = swModel.GetPathName
          longstatus = swModel.SaveAs3(dwgFilePath, 0, 0)
         
         
          'Save Drawing as PDF and close document
         
          PDFpath = "P:\Tooling Assemblies\Tooling Assembly Drawings\" & dwgname & ".pdf"
          longstatus = swModel.SaveAs3(PDFpath, 0, 0)
          swApp.CloseDoc swModel.GetTitle()
         
      End Sub

       

      Function IsFileOpen(filename As String)
          Dim filenum As Integer, errnum As Integer

          On Error Resume Next
          filenum = FreeFile()
          ' Attempt to open the file and lock it.
          Open filename For Input Lock Read As #filenum
          Close filenum
          errnum = Err
          On Error GoTo 0
         
          ' Check to see which error occurred.
          Select Case errnum

              Case 0
               IsFileOpen = False

              Case 70
                  IsFileOpen = True

              ' Another error occurred.
              Case Else
                  Error errnum
          End Select

      End Function

       

      Regards

      Mat