Create macro which automaticallly creates PDF of a report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I want to create a macro that when run will automatically create a PDF of an
access report and save it to a certain folder. Can someone help?

Thanks,
 
You'll need a PDF printer driver to be installed on your machine. Then
you'll need to use VBA code (not a macro) to change the printer assignment
to the PDF driver, print the report, and then change the printer back to the
default printer. Note that this will work using Application.Printers object
in ACCESS 2002 and 2003.
 
Ken,

Thanks for your help. I have a main database that many people use and I am
attempting to create a separate database whose sole purpose is to create pdf
files based on reports. I have an autoexec macro that imports tables in
from the main database and I have scheduled it to run every day. I have
imported various queries and reports from the main database as well. I want
to schedule this to run in the morning on our fileserv. We do have a pdf
write called Cute PDF which is a free writer I downloaded and installed on
our server. So I won't need to applicatioin to switch the printer back and
forth. I only need it to print a report. I want to include this is part of
my autoexec macro. How would I imbed code into this macro and should I still
use the code you were suggesting?

Thanks,

Chuck
 
If the PC on which your database runs has the CutePDF printer set as the
default printer, then all you need do is print the reports (macro action
OpenReport); they'll be printed to PDF format. I haven't used CutePDF in a
while, so I don't recall if it requires user intervention for naming the
file that is to be created -- if it does, a user would need to be involved
when the macro is executing.

Otherwise, Stephen Lebans has a neat PDF utility for creating PDF files --
haven't used it, but other MVPs have raved about its usefulness and
versatility. See http://www.lebans.com/reporttopdf.htm for the info and
code. This will require use of VBA programming, not macro, although you can
run VBA code from a macro using the RunCode action that calls a public
function that then runs the desired VBA code.

Let us know what you decide you want to try to do.
 
Chuck,

If it was mine, I would just open the report in design view, go to the
File|Page Setup menu, on the Page tab select the Use Specific Printer
option, and nominate your CutePDF driver. Then you don't need anything
other than an OpenReport action in your macro.
 
Ken,

Thanks for your help. I actually downloaded and install the lebans
application. It will automatically convert a report into a pdf file. It has
a form in it that lists all of the reports available. There is a button at
the bottom that says "Click here to save this report as a pdf file". When I
click this button it opens the report in pdf format. What I really want to
do is the run this entirely in batch mode. I want to set up a scheduled task
so that at 6:00 am, the pdf file will be created and then saved to a certain
file. Any idea how I go from have to manully click on a report listed on a
form and manually saving the file to a certain folder to actually doing this
as a scheduled task? The report would be done once a week and would have the
same name and location every week.

Thanks,

Chuck W
 
I haven't used Stephen's tool, so I cannot suggest an approach. May I
suggest that you post a new question about the use of the tool? Stephen or
others who've used it are more likely to see your question if you make a new
question.
 
Steve,

Thanks for your help with my issue. I have the cute PDF writer listed as my
default printer. I also can do a macro which will open the report and print
it. The next step is for the program that confirm that I want to save it to
a certain location. If I click Enter then it asks me if I want to overwrite.
I actually have to do a tab and then enter to save it. Basically I want to
create a macro which will print out the report and save it as the same name
to the same location every Sunday. How do I get the macro to do all of these
things?

Thanks,
 
Chuck,

I am not familiar with CutePDF. I use PDF995, and it provides an option
to nominate a default file path/name for output of PDFs. Maybe CutePDF
has the same. Otherwise, I think the user intervention you are being
asked for is related to the PDF printer driver, and not to your Access
procedure as such.
 
Steve,

I appreciate your help with my issue. I have actually downloaded the PDF995
trial version. I am trying to figure out how to nominate a default file like
you mentioned. Do I need to purchase the full version or is this availabe in
the trial version.

Thanks,
 
Chuck,

You can download and install the PDFEdit995 utility, and use the option
under the 'AutoName' tab to set the default file name. Otherwise you
need to manually edit the pdf995.ini file, and I an not sure of the
details how to do this.
 
Back
Top