Public
Sub MakePDF(ByVal strPDFFileName As
String) ' Define the postscript and .pdf file names. Dim strPSFileName As
String Dim xlWorksheet As Worksheet Dim objPdfDistiller As PdfDistiller strPSFileName = Left(strPDFFileName, InStrRev(strPDFFileName, "\")) & "tmpPostScript.ps" ' Print the Excel ActiveSheet to the postscript file Set xlWorksheet = ActiveSheet Call xlWorksheet.PrintOut(copies:=1, preview:=False, ActivePrinter:="Acrobat Distiller", printtofile:=True, collate:=True, prtofilename:=strPSFileName) ' Convert the postscript file to .pdf Set objPdfDistiller = New PdfDistiller Call objPdfDistiller.FileToPDF(strPSFileName, strPDFFileName, "") ' Finally, delete the postscript file Call Kill(strPSFileName) End
Sub
参考以下这个代码哦 会有帮助的 |