0

我正在尝试通过 VBA 与外部 Acrobat 对话窗口进行交互。

我正在使用 MapPoint 生成地图,然后将它们保存为 PDF 文件。一切都通过 VBA 控制。我正在使用地图的“打印输出”方法来保存它们。

    objApp.ActiveMap.PrintOut _
        Title:=PDFTitle, _
        PrintArea:=geoPrintFullPage, _
        PrintQuality:=geoPrintQualityNormal, _
        PrintOrientation:=geoPrintLandscape

以这种方式使用此命令会启动“将 PDF 文件另存为”对话框。在过去的某个时候,我们曾经通过使用 SendKeys 函数将 {Enter} 发送到对话框并关闭它来处理此问题,但这不再有效。

我认为问题在于运行此命令会导致 VBA 执行停止,直到对话框关闭。有什么方法可以安排在对话框打开后执行 Sendkeys 功能?或者有没有办法防止 VBA 执行暂停?

理想情况下,我想首先避免使用该对话框,但这在我当前的设置中似乎是不可能的。在运行命令时指定 OutputFileName 确实会阻止对话框出现,但它会导致保存的文件出现某种问题(它无法打开并且似乎已损坏)。

任何建议表示赞赏!

4

1 回答 1

0

Can you download primopdf and try the following. PrimoPdf is a free print driver that allows you to save as PDF. http://download.cnet.com/PrimoPDF/3000-18497_4-10264577.html

Option Explicit 

Sub PrintToPrimoPDF() 
     Dim strCurrentPrinter As String 
     strCurrentPrinter = Application.ActivePrinter ' save the currently active printer
     On Error Resume Next ' ignore  errors
     Application.ActivePrinter = "PrimoPDF on Ne04:" ' change to PrimoPdf
     Sheet1.PrintOut ' print the sheet1
     Application.ActivePrinter = strCurrentPrinter ' change back to the original printer
     On Error Goto 0 ' resume normal error handling
End Sub 
于 2013-12-05T18:05:58.530 回答