Following codes will save the current active file as PDF in same location. In case you need to work it for only drawing, check the attached macro.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim Path As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Path = Left(swModel.GetPathName, Len(swModel.GetPathName) - 6) & "PDF"
swModel.SaveAs3 "" & Path & "", 0, 0
Save As PDF.swp.zip 7.0 KB
Thanks Deepak, but I do not want to save the PDF to the same file location as the slddrw location. I need to choose a diffrent location on my local drive. My solidworks drawing files that I would be saving as pdf's is on a network drive.
This is the code I like to use:
Dim swModExt As SldWorks.ModelDocExtension
Dim SwModel As SldWorks.ModelDoc2
Dim OutputPath As String
Dim SubDir As String
Dim RetBool As Boolean
Set swModExt = SwModel.Extension
If Dir(OutputPath & SubDir & SwModel.GetTitle & ".pdf") <> "" Then
Kill OutputPath & SubDir & swModel.GetTitle & ".pdf"
RetBool = swModExt.SaveAs(OutputPath & SubDir & SwModel2.GetTitle & ".pdf", 0, 0, Nothing, Errors, Warnings)
Where OutputPath is the folder and SubDir is any sub-directories within that path.
you can use GetTitle() to get the name of the current file. Depending on your Windows Explorer settings you will get the extension returned also.