Ouput Report To PDF Using Code

catbeasy

Registered User.
Local time
Today, 13:19
Joined
Feb 11, 2009
Messages
140
Would like some help on how to output my Access report to a PDF file..

When I do it manually, I select Preview Report, then change the Printer Name to Adobe PDF (as I have had the version of ADOBE that allows for this).. and then click OK. I am then prompted for a location which I enter and it prints the report data as an ADOBE file.

I looked at docmd's: OpenReport and Output To, but they don't have a place where I can change the printer from my default (which is on a network printer) to the PDF selection..

btw, the intrinsic constants for Output To are:

HTML, IIS, RTF, TXT, and XLS. Are there more, can I add PDF?

Any suggestions?

Thanks..
 
I'm pretty sure I've heard that Access 2007 offers PDF. I doubt it's available in Access 2003. I suppose you could output to RTF and then goto a PDF printer (I think you said that Adobe now has a PDF printer). To change printers, maybe try handling the report's Open event.


Private Sub Report_Open(Cancel As Integer)
Dim p As Printer
For Each p In Printers
'Do a msgbox for testing purposes only
'use Control C to copy and paste the device name
MsgBox p.DeviceName 'for testing, use Control-C to get the name
If p.DeviceName = "Adobe PDF Printer" Then Me.Printer = p
Next p
End Sub
 
I'm pretty sure I've heard that Access 2007 offers PDF. I doubt it's available in Access 2003. I suppose you could output to RTF and then goto a PDF printer (I think you said that Adobe now has a PDF printer). To change printers, maybe try handling the report's Open event.


Private Sub Report_Open(Cancel As Integer)
Dim p As Printer
For Each p In Printers
'Do a msgbox for testing purposes only
'use Control C to copy and paste the device name
MsgBox p.DeviceName 'for testing, use Control-C to get the name
If p.DeviceName = "Adobe PDF Printer" Then Me.Printer = p
Next p
End Sub
Ok, thanks, I'll give it a try..
 
I'm using 2007 and the following code exports my report to pdf. strFileNameAndPath is populated prior to the call below:

DoCmd.OutputTo acOutputReport, "rptProjectSheet", acFormatPDF, strFileNameAndPath

Also, I believe that I had to download some info from Microsoft to be able to output to PDF. I also have Professional on my PC so I can select PDF from my printer selection but if I remember correctly you have to have the download too.

If you're not using 2007, try outputing your report to a snapshot file. I used that in previous versions of Access and it works great.
 
Last edited:
Would like some help on how to output my Access report to a PDF file..

I looked at docmd's: OpenReport and Output To, but they don't have a place where I can change the printer from my default (which is on a network printer) to the PDF selection..

Any suggestions?

Thanks..

I use Lebans' solution and it works well:

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

Good luck

SHADOW
 
Hi Magster,

Sorry Catbeasy, don't mean to hijack your thread, but I'm interested in Magster response.

I'm currently using Access 2000, which doesn't support PDF for outputting reports, so I've resorted to the Snapshot, which produces a good image. but the problem I have is the department that I need to send my snapshot to, are unable to open the snapshot.

I know snapshot comes as part of access, but is there some application apart from access that can open and print snapshots. I've tried Paint, I've tried Adobe Reader and MS Publisher and Imaging to name a few, with no success.

Is it a requirement to have Access in order to open, view and print snapshots.

Any assistance pointers would be appreciated.

John
 
Hi Magster,

Sorry Catbeasy, don't mean to hijack your thread, but I'm interested in Magster response.

I'm currently using Access 2000, which doesn't support PDF for outputting reports, so I've resorted to the Snapshot, which produces a good image. but the problem I have is the department that I need to send my snapshot to, are unable to open the snapshot.

I know snapshot comes as part of access, but is there some application apart from access that can open and print snapshots. I've tried Paint, I've tried Adobe Reader and MS Publisher and Imaging to name a few, with no success.

Is it a requirement to have Access in order to open, view and print snapshots.

Any assistance pointers would be appreciated.

John

Two suggestions:

  1. Have the report recipients install the free snapshot viewer from Microsoft.
  2. Use the LeBans ReporttoPDF module and output the report to pdf before sending.
 
Hi - the last posting gave the link for the snapshot download from Microsoft. Its been several years since I created a snapshot file, and it was in Access 2003. I found the code that I used just incase someone else wanted to use it.

DoCmd.OutputTo acOutputReport, , acFormatSNP, , False

I never had the problem with viewing the snapshot file because we all have Microsoft Office.

Hope this helps.

Magster
 
Hi Irish634 and Magster,

Thanks very much for your help guys, that has saved a lot of heatache, most appreciated.

John
 
If you already have a PDF printer installed on the PC, you can use the following code. If you don't have a PDF printer I believe the LeBans PDF code is the best, but requires some .DLL files.
 

Attachments

Hi - what I did was a get a free PDF download patch or whatever from Microsoft which allowed me to use the code I posted earlier. I never added a dll (which I believe is a dynamic linked library) which I wouldn't have a clue how to do.

Magster
 
Ah, I misunderstood your method. Thanks for the clarification, I will have to go try it out.
 

Users who are viewing this thread

Back
Top Bottom