You need to be logged in to view this content. Please login or become a member.


  1. Coder88

    Can you make a macro that will save a drawing as a pdf? The help tutorial isn’t helping me fix my problem.

    • Coder88, I’ll post this later on its own page but in the mean time this should do:

      Dim swApp As SldWorks.SldWorks
      Dim swModel As SldWorks.ModelDoc2
      Dim swDraw As SldWorks.DrawingDoc
      Dim swExport As SldWorks.ExportPdfData
      Dim vSheetNames As Variant

      Sub main()
      Set swApp = Application.SldWorks
      Set swModel = swApp.ActiveDoc
      Set swDraw = swModel
      vSheetNames = swDraw.GetSheetNames
      Set swExport = swApp.GetExportFileData(swExportPdfData)
      swExport.SetSheets swExportData_ExportAllSheets, vSheetNames
      swModel.Extension.SaveAs “C:\export.pdf”, swSaveAsCurrentVersion, swSaveAsCurrentVersion, _
      swExport, Empty, Empty
      End Sub

  2. tmattson

    Currently i’m trying to create a macro to save the flat pattern dxf from the drawing level. The issue i’m having is opening the part after getting information from the drawing level. I’ve tried this example and many other but the file never opens. Below is my dim and open code

    Dim swApp As SldWorks.SldWorks
    Dim Name As String

    Set swApp = Application.SldWorks
    swApp.Visible = True
    Name = Filepath & FileName & “.SLDPRT”
    swApp.OpenDoc6 Name, swDocPART, swOpenDocOptions_Silent, “”, longstatus, longwarnings

    I can upload the rest of the code if needed.
    Any help would be appreciated,

Questions and Comments

You must be logged in to post a comment.