转PDF
下面的程序能够把p1,p2构成的区域打印n份。现在我想用程序将图形转PDF,但我不知道怎样将打印机名设为"Adobe PDF",也不知道怎样设定PDF文件名。
请高手帮忙。
ThisDrawing.ModelSpace.Layout.RefreshPlotDeviceInfo
ThisDrawing.ActiveLayout.PlotType = acWindow
ThisDrawing.ActiveLayout.UseStandardScale = True
ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
ThisDrawing.ActiveLayout.SetWindowToPlot p1, p2
ThisDrawing.Plot.NumberOfCopies = n
ThisDrawing.Plot.PlotToDevice
基本原理如下:
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
谢谢兰州人,我下来慢慢消化。
页:
[1]