These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Saving MS Access reports as PDF from VBA

mmeytin
Registered: Oct 12 2007
Posts: 2

I'm trying to accomplish a seemingly simple thing - I'd like to be able to save Access Reports as PDF with custom filename and directory by clicking on a button on a form. I have been searching up and down for VBA code that would let me do this, without much luck. The methods proposed are at best unreliable, and at worst do not work at all with recent versions of Acrobat. Nothing relevant was found in SDK. Can someone post a code sample that would accomplish such a thing? Can't I control PDF generation via some bundled Active X control? Any information would be much appreciated!

Thanks,
-M-

quantumkev
Registered: Oct 11 2007
Posts: 8
Hello,
I just got done working through the same thing you are trying to accomplish, and here's what I did that finally, worked :

1. First, configure the Adoobe PDF printer on your computer by right clicking on it in the "Printers" folder, then click Properties > Advanced > Printing Defaults. Then, browse to the folder you would like the report saved to where it says "Adobe output folder".2. After you have set up the Adobe printer, add this to your VBA code :

Set myPrinter = Application.Printer
Set Application.Printer = Application.Printers("Adobe PDF")
DoCmd.OpenReport "your_report_name", acViewPreview, , , acWindowNormal
DoCmd.PrintOut acPrintAll, 1, , acDraft, 1
Set Application.Printer = myPrinter

The last line sets the printer back to the original printer. Hope this helps!
danlopez007
Registered: Feb 14 2008
Posts: 10
Can you set the file name for a destination?