基本原理如下: 1. 使用Acrobat Distiller打印激活worksheet or range生成postscript文件 2. 使用Acrobat Distiller API 将postscript转化成 .PDF 文件 其次要做以下几步 A 在VBA工程中引用Acrobat Distiller B 然后,进行Acrobat Distiller的打印设置   ublic
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 细节见http://blog.csdn.net/fangxinggood/archive/2006/02/14/599045.aspx |