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
Dear All
I have been trying to output two Access reports into a PDF. The code I've constructed is a combination of modPDFCreatorAccess2000.bas, which works for 1 report, and Sub PrintToPDF_MultiSheetToOne_Early from Ken Puls (www.excelguru.ca) which prints >1 Excel worksheets to one PDF. My code follows. Please can someone review it and tell me where I've gone wrong. Thank you.
Public Sub PrintTwoReports(RepName1 As String, RepName2 As String)
Dim PDFCreator As PDFCreator.clsPDFCreator
Dim DefaultPrinter As String, c As Long, OutputFilename As String
Set PDFCreator = New clsPDFCreator
With PDFCreator
.cStart "/NoProcessingAtStartup"
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = "C:\"
.cOption("AutosaveFilename") = "Test"
.cOption("AutosaveFormat") = 0 ' 0 = PDF
DefaultPrinter = .cDefaultPrinter
.cDefaultPrinter = "PDFCreator"
.cClearCache
.cPrinterStop = True
DoCmd.OpenReport RepName1, acViewNormal
DoCmd.OpenReport RepName2, acViewNormal
'Wait until the print jobs have entered the print queue
Do Until .cCountOfPrintjobs = 2
DoEvents
Loop
.cCombineAll
.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until .cCountOfPrintjobs = 0
DoEvents
Loop
End With
c = 0
Do While (PDFCreator.cOutputFilename = "") And (c