ConvertReportToPDF from Stephen Lebans

M

Markus Grürmann

Hi ,
First of all i want to thank Stephen Lebans for his very professional work.
I am very happy that I found his side to help me out with many access
problems I had.

Recently I had the problem to convert reports to a PDF file. So I found the
solution and use it now with my little Access Program.
I like to ask you how i can manage to involve a report with

blRet = ConvertReportToPDF(Me.lstRptName, vbNullString, Me.lstRptName.Value
& ".pdf", False, True, 150, "", "", 0, 0, 0)

that use the "Filter" or "Where conditions"

DoCmd.OpenReport stDocName, stView, , "[BE_ID]=" & BeID

the only solution i found was to write the ID to an Form![tempID] field and
refer from my report to this field "report![ID]= forms![tempID] and then use
your ConvertReportToPDF. But in my opinion that is not very elegant.

Markus
 
N

NEWER USER

Download a FREE program called Cute PDF Writer. Install it and run your
report in Preview Mode. Select File/Print from the Menu Bar. Your default
printer will appear. Change it to CutePDF Writer and the coversion will
happen. Save As any name you want. Works flawless - used for years.
 
D

Douglas J. Steele

Of course, you can't use CutePDF programmatically, so it's not really that
great for use with Access.

(Stephen's ReportToPDF is free as well, so that makes no difference in the
comparison between the two products)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


NEWER USER said:
Download a FREE program called Cute PDF Writer. Install it and run your
report in Preview Mode. Select File/Print from the Menu Bar. Your
default
printer will appear. Change it to CutePDF Writer and the coversion will
happen. Save As any name you want. Works flawless - used for years.

Markus Grürmann said:
Hi ,
First of all i want to thank Stephen Lebans for his very professional
work.
I am very happy that I found his side to help me out with many access
problems I had.

Recently I had the problem to convert reports to a PDF file. So I found
the
solution and use it now with my little Access Program.
I like to ask you how i can manage to involve a report with

blRet = ConvertReportToPDF(Me.lstRptName, vbNullString,
Me.lstRptName.Value
& ".pdf", False, True, 150, "", "", 0, 0, 0)

that use the "Filter" or "Where conditions"

DoCmd.OpenReport stDocName, stView, , "[BE_ID]=" & BeID

the only solution i found was to write the ID to an Form![tempID] field
and
refer from my report to this field "report![ID]= forms![tempID] and then
use
your ConvertReportToPDF. But in my opinion that is not very elegant.

Markus
 
K

krissco

Hi ,
First of all i want to thank StephenLebansfor his very professional work.
I am very happy that I found his side to help me out with many access
problems I had.

Recently I had the problem to convert reports to a PDF file. So I found the
solution and use it now with my little Access Program.
I like to ask you how i can manage to involve a report with

blRet = ConvertReportToPDF(Me.lstRptName, vbNullString, Me.lstRptName.Value
& ".pdf", False, True, 150, "", "", 0, 0, 0)

that use the "Filter" or "Where conditions"

DoCmd.OpenReport stDocName, stView, , "[BE_ID]=" & BeID

the only solution i found was to write the ID to an Form![tempID] field and
refer from my report to this field "report![ID]= forms![tempID] and then use
your ConvertReportToPDF. But in my opinion that is not very elegant.

Markus

Markus,

I have a solution for you.

1. Open the report with a whereClause
2. Export it as a snapshot from the Report_Page event
3. Close the report
4. Invoke Stephan's function to convert the .snp to .pdf
5. Cleanup temp files


'Step 1. In my reports, I append a special criteria to the whereClause
' that lets step 2 know to export the document as snapshot.
This way,
' I can use the same report for exporting to pdf, and
standard viewing.
DoCmd.OpenReport rptName, acViewPreview, , whereClause


'Step 2. Place this code (or similar) within your report. Please note:
' The "getTagSnapshotFile()" simply returns a string for a
temp file that I
' regularly use for snapshot storage. You can replace this
with any path/file you choose.
'This report can be opened with TRUE criteria (expressions that always
evaluate as true).
'This is simply a method of passing data to the report - in this
version of Access,
'Docmd.OpenReport does not have an OpenArgs argument.
Private Sub Report_Page()

Static PRINTED As Boolean
If Me.Filter Like "*'EXPORT' = 'EXPORT'*" Then
If PRINTED = False Then
PRINTED = True
DoCmd.OutputTo acOutputReport, , acFormatSNP,
getTagSnapshotFile(), False
End If
End If
End Sub


'Step 3. Place this line after the first DoCmd call. This will close
the report after exporting.
DoCmd.Close acReport, rptName

'Step 4. Check that the file exists (see above note on the
"getTagSnapshotFile()" function.
' If all was successful, invoke the converter. Please note,
"strSavePath" is a string
' variable containing my output path/file. You will need to
replace it with a path of
' your own
'If the export was successful
If Dir(getTagSnapshotFile()) <> "" Then

'Convert .SNP file to the desired .PDF file
ConvertReportToPDF , getTagSnapshotFile(), strSavePath, , False

End If

'Step 5 (not included) - you will want to delete your temporary .snp
file.


Hope this helps,

-Kris
 

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