im trying to write a macro that allows me to pdf the current open drawing but changes the directory to a folder called PDF in the folder that the drawing is in. so far it just does nothing when it runs but doesnt error. i also want to add in something to get the revision custom property from the part or assembly file and add it to the title of the pdf. here is my code so far
Sub main()
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swCustProp As CustomPropertyManager
Dim swView As SldWorks.View
Dim swExportPDFData As SldWorks.ExportPdfData
Dim ConfigName As String
Dim i As Long
Dim valOut1 As String
Dim valOut2 As String
Dim resolvedValOut1 As String
Dim resolvedValOut2 As String
Dim PartNo As String
Dim nFileName As String
Dim swDocs As Variant
Dim PDFpath As String
Dim currpath As String
Dim partnodes As String
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swExportPDFData As SldWorks.ExportPdfData
Dim strFilename As String
Dim status As Boolean
Dim errors As Long, warnings As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Save
status = swModel.Save3(swSaveAsOptions_e.swSaveAsOptions_Silent, errors, warnings)
'change path
If swModel.GetType = swDocDRAWING Then
Set swDraw = swModel
currpath = Left(swDraw.GetPathName, InStrRev(swDraw.GetPathName, "\"))
PDFpath = currpath & "PDF"
If Dir(PDFpath, vbDirectory) = "" Then MkDir PDFpath
'Export to PDF if it is a drawing
If (swModel.GetType = swDocDRAWING) Then
strFilename = swModel.GetPathName
strFilename = Left(strFilename, Len(strFilename) - 6) & "pdf"
strFilename = PDFpath & "\" & strFilename
Set swExportPDFData = swApp.GetExportFileData(1)
swModel.Extension.SaveAs strFilename, 0, 0, swExportPDFData, 0, 0
End If
MsgBox ("Drawing saved as PDF!")
End Sub