Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate Multiple PDF files from Access Reports

Status
Not open for further replies.

mttl

Technical User
Dec 7, 2009
2
CA
thread707-1119207
This code is fantastic! Will save me lots of time. How can it be modified to generate many (30) pdf files at one time? If I run sequencial versions of the command line with different report names and pdf file names, it seems to hang-up.

I'm using Windows XP and Access 2002 but I'm hoping it will work for Windows Vista and Access 2007 as well!
 
The things I found that will reduce hangups with the code are:

Use DoEvents between each call
Sometimes it is also necessary to have a message box. In the code below I commented it out because for that particular set of reports I was running, it seemed DoEvents was sufficient, but other report sets needed the MsgBox. Perhaps instead of message box, you could set up a timer event. Another thing I found out that definitely causes a hangup, if you modify the report and select PDF as the printer and or set the default printer to PDF, the code will hang up. Be sure that each report is set to a printer or default printer other than pdf/Adobe.

Code:
    Call RunReportAsPDF(rptName, rptPath & rptFileName & ".pdf", , PrintChoice)
    DoEvents
    'MsgBox "Printed report to PDF", vbOKOnly
 
Thanks for your reply. DoEvents is a good thought. I was also pointing to Adobe PDF as the default printer. I have changed that now. But still got hangups, which seemed to be on writing the pdf file. I found that if you wrote new files each time (rather than overwriting an existing file) it worked all the way through using Access 2002. Anyone know if this code has been modified for Access2007?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top