' Define the postscript and .pdf file names.
Dim xlApp As Excel.Application '定义EXCEL类
Dim xlBook As Excel.Workbook '定义工件簿类
Dim xlsheet As Excel.Worksheet '定义工作表类
Dim PSFileName As String
Dim PDFFileName As String
Dim joboptions As String
PSFileName = "c:\myPostScript.ps"
PDFFileName = "c:\myPDF.pdf"
joboptions = "c:\dd.joboptions"
' Print the Excel range to the postscript file
Dim MySheet As Excel.Worksheet
MySheet = xlsheet
MySheet.PrintOut(copies:=1, preview:=False, ActivePrinter:="Adobe PDF", printtofile:=True, collate:=True, prtofilename:=PSFileName)
' Convert the postscript file to .pdf
Dim myPDF As ACRODISTXLib.PdfDistiller
myPDF = New ACRODISTXLib.PdfDistiller
myPDF.FileToPDF(PSFileName, PDFFileName, joboptions)