Saving Report to PDF without using DLL OCX


R

Rick Brandt

Daniel said:
Lebans Rpt2PDF is great and easy to distribute! Can`t get any easier!!!
Trust me I tried many ways (Adobe Acrobat, PDFCreator,...) and Lebans is
the
best by Far. Actually on a side note, Acrobat does generate certain lines
from reports into the PDFs and yet Lebans does it perfectly.

Furthermore, I could be wrong, but to use the 'clsPDFCreator' class, do
you not first have to have installed PDFCreator on each pc thus installing
DLLs and much more!?

The problem for many with Lebans' wonderful tool (which I use myself) is
that Access 2010 is going to break it. So for many it won't survive the
long haul.
 
Ad

Advertisements

W

Which1

I found this code on the internet and I am trying to get it to work but I am
stumped.
As far as I can tell it seems to work fine until i get to this piece of code:

Do While (clsPDF.cOutputFilename = "") And (i < (maxTime * 1000 / sleepTime))

The clspdf.cOutputFilename is always empty. I also get a dialog box stating
"This action can't be compleated because the other application is busy.
Choose switch to to activate the busy application and correct the problem."
But I can't select switch to because the app locks up. I have to go into
taskmanager to end the Adobe exe process.

I also had to comment out the handle error because the
modPDFPrinter_PrintPDF function can't be found.

I don't want to have to rely on dlls or ocx files.

Any help would be appreciated
***** Begin Code*****
Public Function PrinttoPDF(ByVal RptName As String, Optional
sAutoSaveDirectory As String, Optional sAutoSaveFileName As String) As Boolean


'initialise
On Error GoTo err_Error
Dim clsPDF As PDFCreator.clsPDFCreator 'Initialise the PDF class
Dim strDefaultPrinter As String
Dim strOutputFileName As String
Dim strSaveDirectory As String
Dim i As Long

'set the success variable to true here but it will be set to
'false if the function fails at any point
PrinttoPDF = True

Set clsPDF = New clsPDFCreator

With clsPDF
..cStart "/NoProcessingAtStartup"
..cOption("UseAutosave") = 1 '1 = True, 0 = False

If sAutoSaveDirectory = "" Then
..cOption("UseAutosaveDirectory") = 0
Else
..cOption("UseAutosaveDirectory") = 1
..cOption("AutosaveDirectory") = sAutoSaveDirectory
End If

If sAutoSaveFileName = "" Then
..cOption("AutosaveFileName") = RptName
Else
..cOption("AutosaveFileName") = sAutoSaveFileName
End If

..cOption("AutosaveFormat") = 0 '0 = PDF
strDefaultPrinter = .cDefaultPrinter
..cDefaultPrinter = "PDFCreator"
..cClearCache
Sleep 1
DoCmd.OpenReport RptName, acViewPreview
..cPrinterStop = False
End With

i = 0

Do While (clsPDF.cOutputFilename = "") And (i < (maxTime * 1000 / sleepTime))
i = i + 1
Sleep 500
Loop
strOutputFileName = clsPDF.cOutputFilename

With clsPDF
..cDefaultPrinter = strDefaultPrinter

Sleep 200
..cClose
End With

If strOutputFileName = "" Then
MsgBox "Creating pdf file." & vbCrLf & vbCrLf & _
"An error has occured: Time is up!", vbExclamation + vbSystemModal
PrinttoPDF = False
'Call HandleError("Report " & sAutoSaveFileName & " did not print",
"modPDFPrinter_PrintPDF")
End If

'error handler and exit
err_Exit:
Set clsPDF = Nothing
Exit Function
err_Error:
PrinttoPDF = False
MsgBox Err.Description
'Call HandleError(Err.Description, "modPDFPrinter_PrintPDF")
Resume err_Exit
Resume

End Function
 
W

WebJunkey via AccessMonster.com

Do you have the free MS Office pdf addin? If so, you can just use outputto
function, like so:

DoCmd.OutputTo acOutputReport, "Cheese Cakes", acFormatPDF, "c:\cheesecake.
pdf", False, "", 0, acExportQualityPrint
 
J

Jack Leach

The problem for many with Lebans' wonderful tool (which I use myself) is
that Access 2010 is going to break it.

Sometimes evolution really does suck. I'm going to go crazy when I get to
the point where I can no longer stay with 2003.

I wonder if 2010 will include new and ridiculous features such as the
normalization-breaking "mulit-value fields" that came with '07 (and not to
mention that wonderful ribbon that everyone has so much fun with!!). Way to
go MS!!!

Sorry, just a little rant...

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
Ad

Advertisements

S

Steve Sanford

There is always the "PDF" printer.

I use the free "Primo PDF" print driver. If you have a report that will
print to a normal printer, then just print to the PDF "printer". It will work
for any version of Access. Nothing to add to your Access project.
 
Ad

Advertisements


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