Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ConvertReportToPDF from Stephen Lebans

181 views
Skip to first unread message

Markus Grürmann

unread,
Jun 16, 2008, 7:02:56 AM6/16/08
to
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


NEWER USER

unread,
Jun 16, 2008, 5:43:00 PM6/16/08
to
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.

Douglas J. Steele

unread,
Jun 16, 2008, 6:53:45 PM6/16/08
to
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
http://I.Am/DougSteele
(no private e-mails, please)


"NEWER USER" <NEWE...@discussions.microsoft.com> wrote in message
news:ACC0354B-6432-45C8...@microsoft.com...

krissco

unread,
Jun 27, 2008, 1:00:09 AM6/27/08
to
On Jun 16, 3:02 am, Markus Grürmann <markus_gruerm...@hotmail.com>
wrote:
> Hi ,
> First of all i want to thank StephenLebansfor his very professional work.

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

0 new messages