Solidworks BatchPDF w/ Revision In FileName

I've got this batch file, it works great, the only problem is that it still wont put the revision in the filename. Can anyone help, what am i missing?

Imports

SolidWorks.Interop.sldworks

Imports

SolidWorks.Interop.swconst

Imports

System

Imports

System.IO

Imports

System.Windows.Forms

Partial

Class SolidWorksMacro

Public Sub main()

Dim swDoc As ModelDoc2 = Nothing

Dim longstatus As Integer = 0

Dim longwarnings As Integer = 0

Dim FileToOpen As String

Dim SourcePath As String

'show a folder browser dialog to the user

Dim FolderDia As New FolderBrowserDialog

FolderDia.Description =

"Select a folder to process"

Dim diaRes As DialogResult = FolderDia.ShowDialog

'if the user clicks anything other than OK, exit

If Not diaRes = DialogResult.OK Then

Exit Sub

End If

'source path is the folder the user selected

SourcePath = FolderDia.SelectedPath

'use DirectoryInfo to get all drawing files in the selected folder

Dim SourceDir As New DirectoryInfo(SourcePath)

Dim sourceFiles() As FileInfo

sourceFiles = SourceDir.GetFiles(

"*.SLDDRW")

'loop through all drawing files in the sourceFiles array

For Each DrawingFile As FileInfo In sourceFiles

FileToOpen = DrawingFile.FullName

'simple SolidWorks call to open a file

swDoc = swApp.OpenDoc(FileToOpen, swDocumentTypes_e.swDocDRAWING)

Dim swCustPrpMgr As SolidWorks.Interop.sldworks.CustomPropertyManager

Dim swModel As Object = swApp.ActiveDoc

swCustPrpMgr = swModel.Extension.CustomPropertyManager(

"")

Dim rev As String

swCustPrpMgr.Get3(

"Revision", False, "", rev)

If rev = "-" Then

rev =

"*"

Else

rev =

"_" + rev

End If

'change the file extension to PDF

Dim PDFName As String

PDFName = IO.Path.ChangeExtension(FileToOpen + rev,

".PDF")

'create the PDF and close the drawing

Dim ret As Boolean = swDoc.Extension.SaveAs(PDFName, 0, 0, Nothing, longstatus, longwarnings)

swApp.CloseDoc(FileToOpen)

Next

End Sub

'''

''' The SldWorks swApp variable is pre-assigned for you.

'''

Public swApp As SldWorks

End

Class

SolidworksApi macros