MS Access 2003 - Printing to PDF w/o opening the PDF (1 Viewer)

malxvc

Registered User.
Local time
Today, 04:13
Joined
Sep 12, 2012
Messages
21
I have the following code to save a report as a PDF from my Access form:
Code:
Private Sub btnPrint_PDF_Click()
Dim strDefaultPrinter As String
Dim stDocName As String
strDefaultPrinter = Application.Printer.DeviceName
stDocName = "Sales_Incentive_Report"
Set Application.Printer = Application.Printers("PDF Printer")
    DoCmd.OpenReport "Sales_Incentive_Report", acViewDesign, , , acHidden
    Reports!Sales_Incentive_Report.Caption = LastName & "_Sales_Incentive_Report"
    DoCmd.Close acReport, "Sales_Incentive_Report", acSaveYes
 
    DoCmd.OpenReport stDocName, acViewNormal
    DoCmd.Close acReport, "Sales_Incentive_Report"
 
End Sub

The issue I'm having is that after I click the command button to save the report as a PDF, the PDF is automatically opened. I have to run this process for 40-60 employees...I don't want 40-60 PDF files opened on my computer at once.

This code has to remain the same, as it is the only way I have been able to save a report as a PDF with a dynamic naming convention, so the acViewNormal portions cannot be changed to acHidden, or the caption section of the code wouldn't apply (at least I think that would break it, idk.. I'm new to Access).

Is there anything I could add to the end of this code to close the PDF that was just created? It has to open for the name to generate in the 'Save As' dialogue box, but how can I close it automatically?

Thanks in advance.
 

boblarson

Smeghead
Local time
Today, 02:13
Joined
Jan 12, 2001
Messages
32,059
Open your PDF PRINTER from the PRINTERS AND FAXES (if using WinXP) or DEVICES (if on Vista or Win7) and there might be a setting like what I have for my Adobe Acrobat Printer - VIEW ADOBE PDF RESULTS and, in my case, uncheck that box.
 

malxvc

Registered User.
Local time
Today, 04:13
Joined
Sep 12, 2012
Messages
21
I figured it would be a setting in the PDF Printer properties, but couldn't find anything going through the program itself - however, changing the properties through Device Manager looks to have done the trick.

Great stuff, boblarson

Thanks
 

Users who are viewing this thread

Top Bottom