By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,635 Members | 913 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,635 IT Pros & Developers. It's quick & easy.

How to print a report to a PDF file via code?

P: n/a
JSB
I am new to Access and am hoping an Access guru out there can help me.
I am using an Access 2002 project to report on a SQL Server database.
I am reporting various information for around 100 different Clinics
that are affiliated with our hospital. Each Clinic is supposed to get
its own report, named "Clinic ABC - FY2004 Q4.pdf".

I would like to push one button and have all of the pdf files created.
Instead, I am running the report 100 different times, giving it the
Clinic Primary Key each time, and then manually typing in the file
name each time. I feel like there has to be a better way.

I have Adobe Acrobat so I can print to PDF format and I figured out
how to cycle through my recordset of Clinic primary keys, but how to I
print to a file and specify the resulting file name in code?

Any help would be greatly appreciated.
Thanks,
Jana
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
HJ
This is a code snippet I used in an Excel macro. With some adjustments it
should work in an Access environment as well. It speaks for itself, although
the line with ActiveWindow will have to be replaced of course. I used
CutePDF.

You basically print to the PDF printer and type the name and press Enter
with the SendKeys commands.

HJ

'Print the report
ActiveWindow.SelectedSheets.PrintOut Copies:=1,
ActivePrinter:=strPrinterName

'If this report is saved as PDF, enter the file name
If strPrintPDF = "True" Then
SendKeys "YourReportName.pdf", True 'Send PDF file name
SendKeys "{ENTER}", True ' Send Enter to save file
End If

"JSB" <ja*********@hotmail.com> wrote in message
news:44**************************@posting.google.c om...
I am new to Access and am hoping an Access guru out there can help me.
I am using an Access 2002 project to report on a SQL Server database.
I am reporting various information for around 100 different Clinics
that are affiliated with our hospital. Each Clinic is supposed to get
its own report, named "Clinic ABC - FY2004 Q4.pdf".

I would like to push one button and have all of the pdf files created.
Instead, I am running the report 100 different times, giving it the
Clinic Primary Key each time, and then manually typing in the file
name each time. I feel like there has to be a better way.

I have Adobe Acrobat so I can print to PDF format and I figured out
how to cycle through my recordset of Clinic primary keys, but how to I
print to a file and specify the resulting file name in code?

Any help would be greatly appreciated.
Thanks,
Jana

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.