AnsweredAssumed Answered

HELP: Inserting custom property value in file name during save as macro

Question asked by Matt Jones on Jul 16, 2015
Latest reply on Jul 17, 2015 by Ivana Kolin

Hey Guys,


I have written (with your help) a macro that saves all open drawings (or files maybe doesn't matter) and closes. This works great!


I am wondering if I can add the revision letter  to the file name in a specific place when the macro saves it as a PDF?


The naming convention for drawings at the company I work for puts a -A after the part number but before the description in the file name of the PDF. eg. "234101-100-01-A Beam Fabrication.pdf" when the drawing part name is "234101-100-01 Beam Fabrication.slddrw"


The revision is a custom property from the part document ( $PRPSHEET:"Revision" )


So my rambling aside can insert put the -$PRPSHEET:"Revision" 13 characters in from the left while saving as a pdf in my macro???


Any help would be greatly appreciated (please see my macro code below and feel free to modify it )




Dim swApp As SldWorks.SldWorks

Dim Part As SldWorks.ModelDoc2


Sub main()


Set swApp = Application.SldWorks


Dim FilePath As String

Dim Pathsize As Long

Dim PathNoExtension As String

Dim NewFilePath As String


swDocs = swApp.GetDocuments

     For i = 0 To UBound(swDocs)

          Set Part = swDocs(i)

          If Part.GetType = swDocDRAWING Then

               FilePath = Part.GetPathName

               Pathsize = Strings.Len(FilePath)

               PathNoExtension = Strings.Left(FilePath, Pathsize - 6)

               NewFilePath = PathNoExtension & "pdf"


               Part.SaveAs2 NewFilePath, 0, True, False


               swApp.QuitDoc Part.GetTitle   


          End If

      Next i


End Sub