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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application.Printers method?

Status
Not open for further replies.

chaoma

Technical User
Apr 17, 2005
101
US
Hi,

I am new to Access.

I been trying to print my Access 2000 Report to PDF without any success. After a long search, I found the following fucntion.

Public Function PrinttoPDF(rptname As String, outputfname As String) As String

Set Application.Printer = Application.Printers("Adobe PDF")
DoCmd.OpenReport rptname, acViewNormal
Application.Printer = Nothing

End Function

PrinttoPDF("invoice","c:\pdfile.pdf")

When running this module, I got an error message Application.Printers method or data member not found.

How do I get Printers method to work?
Do I need to download it from somewhere?

It doesn't appear to exist.

What is "Adobe PDF" argument? Is it an actual PDF printer like Acrobat Distiller or HP OfficeJet PS?


Thank you for your assistance.
 
The Printers collection only includes printer drivers that are already installed. You need a PDF printer installed.

Adobe Distiller is the original, but there are many others available (Google for 'PDF printer') at all prices from free upwards. PDF995 do a fairly good nagware version if you want to get started cheaply

BTW you will generally get better answers to Access questions in one of the dedicated Access forums on this site. Do a 'Find a Forum' search at the top of the page

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
 
And, as an additional downer, the Printers collection didn't become available in Access until the 2002 (xp) version. If you're interested, the pages linked from here Change printers from code is supposed to be able to do this in 2000 and lower versions.

Roy-Vidar
 
Thanks. I have another PC with Office 2003, and it worked.

However, the file argument "c:\pdffile.pdf" doesn't really do anything in the function.

I find that I can put PDF files in a certain folder, by creating another PDF printer:

1. Create a Generic/text printer.
2. Use LTP1 port.
3. After printer finish installation, change printer driver to PDF Writer.
4. Add a new port for PDF Writer. Point it to the new folder such as c:\pdffile\*.pdf
5. Change printer name to anything you want. Then change your PrinttoPDF function to poin to that printer.

I am not sure, if this will work with Acrobat Distiller/Acrobat 5. If it doesn't, do a custom installation and put a checkbox next to PDF Writer.
 
Also,

6. The file name of PDF file will be generate correctly if you set the caption of your REPORT in Access: Manual or through your code.

7. Go to printer setting, set up the "Printing Preferences..." to as follow to avoid Acrobat prompting you for file name.
a. Uncheck the box for View Result in acrobat.
b. Uncheck the box for Prompt for PDF file name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top