Saving an Access report to a PDF (Acrobat 6.0) document with a custom file name
Posted on 2006-05-05
I am using Acrobat 6.0. Initially I have tried to save an Access report to a PDF file using the Acrobat Distiller but came across an error message “ActiveX component cannot create object –429”. I have tried all sorts of things based on information that I got but not able to get rid of the same.
Alternatively, I have turned the PromptForFileName off in the printer preferences. I have created a value name in which I am able to store the path and file name in the registry and also a value by name persistent that ensures that the contents are not wiped out. I have used the following code.
Application.Printer = Application.Printers("Adobe PDF")
SaveSetting "XYZ", "XYZ", "PDFFileName", pdfPath & filename & ".pdf"
DoCmd.OpenReport ReportName, acNormal
Set Application.Printer = Nothing
The value name PDFFileName is getting the value passed by me (path and the file name) and the PDF file is getting generated. But the file name is the default name of the report and not the value that I am passing to PDFFileName. I have the following questions in this regard:
1. Can I make the file name to be the one that I am passing to a registry value? If yes, then how?
2. Can I pass the location where the file is to be saved in the above way without changing the port for the Adobe PDF printer? If yes, then how?
I would appreciate if someone can throw light on this method of saving an access report to a PDF format.