Access Report Output to PDF (Acrobat)

J

JR_06062005

I'm trying to automate the process of creating a PDF file from an Access
report. By automate I mean the user clicks on a button or menu choice.

Assume Acrobat (and thus Acrobat Distiller and Acrobat Writer) are
installed. I use the following code:

Dim prtFirst As Printer, stName As String
Dim rptCurrentReport As Report
stName = Printer.DeviceName
Set Printer = Printers("Acrobat PDFWriter")
Set rptCurrentReport = Screen.ActiveReport
Application.CurrentUser
DoCmd.PrintOut acPrintAll

When the code executes, the process appears to work, but then the output
disappears. Acrobat does not open as it would if I manually printed to
PDFWriter and a PDF output is no where to be found.

Is there a way to get the same results of manully printing to PDFWriter;
getting a dialog box which gives me the opportunity to designate a file name
and where the file is to be saved, and then opening the document in Acrobat?
 
A

Albert D.Kallal

Actually, why don't you dump the use of Acrobat anyway.

Stephan has a routine which has the following features

You do not need to have, purchase, nor installed Acrobat
You do not need to try and change the default printer..since it is
not a printer drive

You would of course have to use some code to prompt the user for the output
file name..but that is *much* better then trying to use a printer, change
printer..and hope that the acrobat software is installed correctly...

You can find the free pdf creator code here....

http://www.lebans.com/reporttopdf.htm
 
A

Andy

I use a program which youcan purchase inexpensively on the net called Visage.
It allows you to print to a virtual PDF file and prompts you for a file name.
 
S

SA

Jr:

If you want to fix your code so that it prints but prompts, its pretty
simple, the code would look like this:

Dim objPrinter as Printer, objOrigPrinter as Printer
Dim strRptName as String

objOrigPrinter = Application.Printer
Set objPrinter = Printers("Acrobat PDFWriter")
Application.Printer = objPrinter
strRptName = Screen.ActiveReport.Name
'Assumes that report is in preview
DoCmd.SelectObject acReport, strRptName
DoCmd.PrintOut acPrintAll
DoEvents
Application.Printer = objOrigPrinter

On the other hand if you want to automate the output where the user doesn't
have to provide a file name or location (i.e. the app does it,) then take a
look at our PDF and Mail Library for Access, which works with Acrobat and
many other PDF printers. You'll find it in the Developer Tools area of our
web.
 
A

Albert D.Kallal

Andy said:
I use a program which youcan purchase inexpensively on the net called
Visage.
It allows you to print to a virtual PDF file and prompts you for a file
name.

Well, there are several inexpensively solutions. I use the folwing for
creating pdf files, and it is free.

It is absolutely Free,

And free means no watermarks, no nag screens, no annoying Popup
advertisements, no time limits etc.

It is also very fast, and works very well. I highly recommend it.

http://www.acrosoftware.com/products/cutepdf/Printer.asp


However, Visage, or cutepdf prompts you for a file name. Further, both
requite you to install software, and setup a printer driver.

Stephens solution is much better, since not only is it free, but you DO NOT
have to install the software either. (thus, re-distribution is easy..and you
don't even has to install a pdf printer).
 
J

JR_06062005

I used the software and it works--almost. I'm printing a report landscape on
legal paper. It losses the fromatting in some of the columns on the right
side of the page. I tried creating a snapshot file and then PDF manually
and that works. But for reason the program changes some of the report
formatting.
 
J

JR_06062005

The script does not work. If I change line 4 from
Application.Printer = objPrinter
to
Set Application.Printer = objPrinter

It works, but sends the file to the printer rather than create a PDF.
 
S

Stephen Lebans

Can you send me your MDB containing the problem report so I can debug here?

The issue you describe sounds like it matches one from an older release of
the StrStorage.DLL file. I've seen cases where people download the newer
version and forget to delete the older version that they copied to their
Windows\System folder.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
J

JR_06062005

I'm not sure how to send it to you.

Stephen Lebans said:
Can you send me your MDB containing the problem report so I can debug here?

The issue you describe sounds like it matches one from an older release of
the StrStorage.DLL file. I've seen cases where people download the newer
version and forget to delete the older version that they copied to their
Windows\System folder.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top