0

I am trying to interact with an external Acrobat dialog window through VBA.

I am using MapPoint to generate maps and then save them as PDF files. Everything is controlled through VBA. I am using the "PrintOut" method of the maps to save them.

    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. 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.

I think the problem is that running this command causes VBA execution to stop until the dialog box is closed. Is there any way I could schedule a Sendkeys function to execute after the dialog opens? Or is there a way to prevent VBA execution from pausing?

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).

Any suggestions are appreciated!

Community
  • 1
  • 1
Iggy25
  • 72
  • 9

1 Answers1

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 
  • I am already using a printer driver that prints to PDF. That is how I am saving as a PDF. Also, I am not printing an Excel sheet, I am printing a MapPoint map. Is there any reason why this would work differently than what I am doing now? – Iggy25 Dec 06 '13 at 17:42