473,799 Members | 3,149 Online
Bytes | Software Development & Data Engineering Community
+ 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 2084
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.Se lectedSheets.Pr intOut 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*********@ho tmail.com> wrote in message
news:44******** *************** ***@posting.goo gle.com...
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
14378
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 display the graph but it is not possible to send query parameters to an OLE graph on a report (or programatically change any properties of an OLE Graph). However with a Form you do have the ability to change the RowSource of
5
5828
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 attachment to the email consistently does not display all of the lines it should in one of the GroupFooters. I am using the Print event in the report to print lines multiple times in a groupfooter depending on an integer set elsewhere in the VBA...
16
660
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 brain got stuck on it..sorry! Hi: I need some help writing code that will "print" a report using Cute PDF.
5
2510
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. In *preview* I can hide or move objects on reports's event with VBA. I can correctly know page number, fields value and I can hide or move object. All perfect.
7
2642
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 to a file (in the printer selection screen of the print routines) it gives me a file named what I wanted, but is just garbage. Can't read it. TIA ron
1
8648
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 viewer's gui button. I have a Windows XP sp2 Client machine used for development, it has Visual Studio 2005 sp1 and CR XI R2 Developer Version. My webserver is running Windows Server 2003 sp1, IIS 6.0, has CR XI R2 developer. I have a working...
2
9980
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 printer settings to print. I wanted the print preview to appear the same for all users (i.e. a default page size of 8.5x14 (legal) and portrait mode). Many users have different printers as their default (plotters etc..) and I found that various...
12
3544
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 print the report three times, but do not know how
11
7342
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 is run again? This is causing certain error problems. 1 Why does the code run for a print preview when the report already exists? 2 What command do I use in code to find out if a report (or any other object for that matter) is already...
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10484
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
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 we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.