Set path/reportname when outputing

  • Thread starter Thread starter Akom
  • Start date Start date
A

Akom

I finally got my report to output as a pdf file using a
combo box on my form, with a selection of available
printers, and the code listed below; however, the default
output is to my desktop when the "Acrobat Distiller" is
selected. Is it possible to send the pdf output file to
the "strFile_pdf" path below?

Private Sub PDF1_Click()
Dim strFile_ps As String, strFile_pdf As String, Path As
String
Dim objPrinter As String
Dim DT As String

DT = DateSerial((Year(Now())), (Month(Now())), (Day(Now
())))
Path = "C:\database\security\PDF\"
strFile_pdf = Path & DT & ".pdf"
strFile_ps = "Time by Site"

' Store the default printer to reset at end
objPrinter = ActivePrinter
' Set output to selected printer
ActivePrinter = Me.CboPrinters
' Run the report
DoCmd.OpenReport strFile_ps, acViewNormal
' Restore the default printer setting
ActivePrinter = objPrinter

End Sub

Is there another way to print the report besides using
DoCmd.OpenReport with the "acViewNormal" as the code to
print it? In plain English the line would read something
like, "Print "strFile_ps," if "Acrobat Distiller" is the
selected destination, then output the file to
the "strFile_pdf" path."

The code would probably be something like this:
If objPrinter = "Acrobat Distiller" Then
Some code to send to the "strFile_pdf" path.
Else
DoCmd.OpenReport strFile_ps, acViewNormal
End If

Thanks in advance,
Al
 
Akom:

Adobe Distiller has no exposed method to allow you to output a PDF file to a
specific path. You might want to look at our PDF and Mail Library for Access
which would allow you to do that quite easily as follows:

Dim objPDF as New PDFClass
Const PDFENGINE_DISTILLER = 2
With objPDF
.ReportName = YourReportNameHere
.ReportWhere = "Some SQL WHERE"
.Outputfile = "c:\some dir\some file.pdf"
.PDFEngine = PDFENGINE_DISTILLER
.PrintImage
End With

You'll find it on our web

HTH
 
Back
Top