我想我找到了答案。这是工作中有人建议的一种解决方案(如果有人觉得它有用,那就太好了)。
AcroEXch 类(或我知道的一组方法)中没有可用的方法将非 pdf 文件转换为 pdf 文件。相反,您必须使用 pdf Distiller 首先将文件转换为 postscript,然后您可以使用 PDFDistiller 类写入 pdf。这是代码的sn-p:
'1.打开正在转换为 pdf 的 excel:
xlReport.activate
xlReport.range("a1").select
dim PdfFilePath
PdfFilePath = ""
dim PsFilePath
PsFilePath = ""
'2.将 Excel 文件打印到 postscript 文件
xlBook.activesheet.PrintOut , , 1, , "Adobe PDF on Ne01:" ,TRUE, , PsFilePath
Dim oDistiller
设置 oDistiller = CreateObject("PDFDistiller.PDFDistiller.1")
oDistiller.FileToPDF sPsFilePath, sPdfFilePath, ""
' 关闭 Excel - 不保存。
'在下面 3 行注释下进行调试
xlApp.displayalerts=false
xlApp.quit
设置 xlApp=nothing