Using PDF Creator from MS Access
Submitted by jasonbeach on Thu, 2007-12-06 23:54.
I am wanting to output various reports from a MS Access database I have. I can print to the PDFCreator with no problem. My question is, is there a way to print two or more reports to one pdf file? Is the an object model for the pdfCreator class?
Thanks,
Jason
Thanks for your post. VBA does have an object browser, but I guess I was hoping for a little more detailed documentation about what each method does and what arguments it requires.
Also, the .cCombineAll method doesn't seem to be working. I'm still winding up with four .pdfs (that don't have the autosave filename I give it). Here's my code:
Sub TOLsPDF()
Dim currentPrinter As Printer
Dim intCtr As Integer
Dim pdfMaker As PDFCreator.clsPDFCreator
Dim pdfOptions As PDFCreator.clsPDFCreatorOptions
Dim pdfParams As String
Dim Start As Single
Set currentPrinter = Application.Printer
Set pdfMaker = New PDFCreator.clsPDFCreator
'the next few lines just change the printer in Access
'to PDFCreator
intCtr = 0
For Each prtLoop In Application.Printers
If prtLoop.DeviceName = "PDFCreator" Then
Set Application.Printer = Application.Printers(intCtr)
Exit For
Else
intCtr = intCtr + 1
End If
Next prtLoop
'Start PDFCreator
pdfParams = "/NoProcessingAtStartup"
If Not pdfMaker.cStart(pdfParams) Then
'we have a situation - handle it.
End If
Set pdfOptions = pdfMaker.cOptions
With pdfOptions
.UseAutosave = 1
.AutosaveDirectory = CurrentProject.Path & "\"
.AutosaveFilename = "test"
.AutosaveFormat = 0
.StartStandardProgram = 1
End With
pdfMaker.cPrinterStop = True
DoCmd.OpenReport "rptActive"
DoCmd.OpenReport "rptInActive"
DoCmd.OpenReport "rptClosed"
DoCmd.OpenReport "rptStatusChanges"
pdfMaker.cCombineAll
pdfMaker.cPrinterStop = False
End Sub
Thanks,
Jason