473,467 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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
1 2051
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Pat | last post by:
I would like to send the Print Preview of a MS Access form to a Snapshot file. The form contains an OLE graph. BACKGROUND A snapshot of a report is possible. If I could I would use a report to...
5
by: Tom Louchbaum | last post by:
When I preview my Access 2000 Report it looks fine. When I Email the report using DoCmd.SendObject acSendReport, "Report", acFormatRTF, "To Address", , , "Subject", , False the resulting...
16
by: John Baker | last post by:
HI; I feel like a fool..I put CUTE FTP in my last request for help --it should have been CUTE PDF! I have FTP on my mind because I have been working on a web based application, and somehow my...
5
by: Max ©® | last post by:
Hi all, I'm going crazy... I've report with subreport. I want simply move some objects on report and subreport according to fields value. For example I want hide a label when a field is empty. ...
7
by: Ron | last post by:
Hi All, Is it possible to have Access print a report, identical to one that would print to a printer, only print to a "standard" text file? I can't find it in help and when I try to just print...
1
by: Kbalz | last post by:
Having a really hard time finding solid examples on deploying a CR .NET applcation on my intranet. I'll explain what I've done so far, and toward the bottom is where I can't print using the report...
2
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
11
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.