Call ConvertReportToPDF

A

Antney

Hi,

How do I call 'Call ConvertReportToPDF'? Everytime I run this code, I get
the 'Sub or Function not defined.

Also, will this take care of the reports naming? When I comment out the
'Call ConvertReportToPDF' and run the code, it runs ok but my reports still
do not get named correctly, I have to manually type them in. The 'SiteName',
in my code, is in the query and table that I am using so I can't figure out
why they're not automatically being named.

Thank you!

Here's my code:

Option Compare Database
Option Explicit

Private Sub cmdPrintReports_Click()
On Error GoTo Err_cmdPrintReports_Click

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strReport As String
Dim strDocName As String

Set db = CurrentDb()
Set rs = db.OpenRecordset("qrySchools", dbOpenSnapshot)
strReport = "rptStudentDataSheet_0708"

With rs
Do Until (.EOF Or .BOF) = True
DoCmd.OpenReport strReport, acViewNormal, , "School = " &
rs("School")
Reports(strReport).Visible = False
strDocName = "C:\Documents and Settings\anthony.johnson\My
Documents\Anthony\ " & !SiteName & ".pdf"
Call ConvertReportToPDF(strReport, , strDocName, False, False)
DoCmd.Close acReport, strReport
rs.MoveNext
Loop
End With

Exit_cmdPrintReports_Click:
'Cleanup
On Error Resume Next
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
Exit Sub

Err_cmdPrintReports_Click:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in Test subroutine..."
Resume Exit_cmdPrintReports_Click
End Sub
 
A

Albert D. Kallal

does your code compile?

While looking at the code (and, it looks ok), go debug->compile....

There is some additional instructions and notes here
http://www.lebans.com/reporttopdf.htm

I would perhaps download the latest version of this pdf software......and
take a quick read of the above notes....
 

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