Set myInDesign = CreateObject("InDesign.Application.CS2")
Set myFileSystemObject = CreateObject("Scripting.FileSystemObject")
If myInDesign.Documents.Count <> 0 Then
Set myDocument = myInDesign.Documents.Item(1)
myFolderName = "c:\ServerTestFiles"
If myFileSystemObject.FolderExists(myFolderName) Then
myExportPages myInDesign, myDocument, myFolderName
End If
End If
Function myExportPages(myInDesign, myDocument, myFolderName)
myBaseName = myDocument.Name
For myCounter = 1 To myDocument.Pages.Count
myPageName = myDocument.Pages.Item(myCounter).Name
myInDesign.PDFExportPreferences.PageRange = myPageName
myPageName = Replace(myPageName, ":", "_")
myFilePath = myFolderName & "\" & myBaseName & "_" & myPageName & ".pdf"
myDocument.Export idExportFormat.idPDFType, myFilePath
Next
End Function