简体   繁体   English

Adobe“另存为”对话框-MapPoint Excel VBA

[英]Adobe “Save as” dialog boxes - MapPoint Excel VBA

I am trying to interact with an external Acrobat dialog window through VBA. 我正在尝试通过VBA与外部Acrobat对话窗口进行交互。

I am using MapPoint to generate maps and then save them as PDF files. 我正在使用MapPoint生成地图,然后将其另存为PDF文件。 Everything is controlled through VBA. 一切都通过VBA控制。 I am using the "PrintOut" method of the maps to save them. 我正在使用地图的“ PrintOut”方法来保存它们。

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

Using this command in this way launches a "Save PDF file as" dialog box. 以这种方式使用此命令将启动“将PDF文件另存为”对话框。 At some point in the past we used to deal with this issue by using the SendKeys function to send {Enter} to the dialog and close it, but this no longer works. 在过去的某个时候,我们曾经通过使用SendKeys函数将{Enter}发送到对话框并关闭它来处理此问题,但是这种方法不再起作用。

I think the problem is that running this command causes VBA execution to stop until the dialog box is closed. 我认为问题在于运行此命令会导致VBA执行停止,直到关闭对话框。 Is there any way I could schedule a Sendkeys function to execute after the dialog opens? 有什么办法可以安排对话框打开后执行Sendkeys函数? Or is there a way to prevent VBA execution from pausing? 还是有办法防止VBA执行暂停?

Ideally, I would like to avoid having the dialog box in the first place, but that does not appear to be possible with my current setup. 理想情况下,我想避免首先出现对话框,但是在当前设置中似乎无法实现。 Specifying the OutputFileName when running the command does prevent the dialog from appearing, but it causes some kind of problem with the saved file (it can't be opened and appears to be corrupt). 在运行命令时指定OutputFileName确实可以防止对话框出现,但是会导致保存的文件出现某种问题(无法打开它,并且看起来已损坏)。

Any suggestions are appreciated! 任何建议表示赞赏!

Can you download primopdf and try the following. 您可以下载primopdf并尝试以下方法吗? PrimoPdf is a free print driver that allows you to save as PDF. PrimoPdf是免费的打印驱动程序,可将其另存为PDF。 http://download.cnet.com/PrimoPDF/3000-18497_4-10264577.html 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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM