Stephan, I am not a programmer by trade, but I am trying. Here is how I put
the code together, but I get a message saying the program cannot uncompress
the snapshot file.
Private Sub cmdOpen_Click()
Dim strDocName As String
Dim strWhere As String
Dim strWhereApp As String
Dim strSQL As String
Dim strApprover As String
Dim rs As Recordset
Dim db As Database
Dim strSnap, strPDF As String
strDocName = "rptSoxJuly"
'strApprover = "Keith Gustely"
Dim qdf As QueryDef
Set qdf = DBEngine(0)(0).QueryDefs("rptSOXJuly")
Set db = CurrentDb()
Set rs = db.OpenRecordset("DistinctApprover", DB_OPEN_TABLE)
rs.MoveFirst
Do While Not rs.EOF
With qdf
strApprover = rs.Fields("AppName").Value
strWhereApp = "Where Approvers.AppName = " & "'" &
rs.Fields("AppName").Value & "'"
'strWhere = "Approvers.AppName =" & strWhereApp
strSQL = "SELECT AS400CSTCTR.*, Approvers.AdminApproverName,
Approvers.AppName FROM AS400CSTCTR INNER JOIN Approvers ON
AS400CSTCTR.dspSysCostCenter=Approvers.CSTCTR " & strWhereApp
'.SQL = "SELECT AS400CSTCTR.*, Approvers.AdminApproverName,
Approvers.AppName FROM AS400CSTCTR INNER JOIN Approvers ON
AS400CSTCTR.dspSysCostCenter=Approvers.CSTCTR WHERE ((Approvers.AppName) =
(strApprover))"
.SQL = strSQL
DoCmd.OpenReport strDocName, acViewPreview
DoCmd.OutputTo acOutputReport, , acFormatSNP, "c:\windows\SOXReports\SNP\" &
strApprover & ".snp"
strSnap = "c:\windows\SOXReports\SNP\" & strApprover & ".snp"
strPDF = "c:\windows\SOXReports\PDF\" & strApprover & ".pdf"
DoCmd.Close acReport, "rptSOXJuly", acSaveNo
'Private Sub cmdReportToPDF()
' Save the Report as a PDF document.
' The selected report is first exported to Snapshot format.
' The Snapshot file is then broken out into its
' component Enhanced Metafiles(EMF), one for each page of the report.
' Finally, the EMF's are converted to PDF pages within the master
' PDF document.
' The function call is:
'Public Function ConvertReportToPDF( _
'Optional RptName As String = "", _
'Optional SnapshotName As String = "", _
'Optional OutputPDFname As String = "", _
'Optional ShowSaveFileDialog As Boolean = False, _
'Optional StartPDFViewer As Boolean = True, _
'Optional CompressionLevel As Long = 0, _
'Optional PasswordOwner As String = "", _
'Optional PasswordOpen As String = "", _
'Optional PasswordRestrictions As Long = 0, _
'Optional PDFNoFontEmbedding as Long = 0 _
') As Boolean
' RptName is the name of a report contained within this MDB
' SnapshotName is the name of an existing Snapshot file
' OutputPDFname is the name you select for the output PDF file
' ShowSaveFileDialog is a boolean param to specify whether or not to display
' the standard windows File Dialog window to select an exisiting Snapshot file
' CompressionLevel - not hooked up yet
' PasswordOwner - not hooked up yet
' PasswordOpen - not hooked up yet
' PasswordRestrictions - not hooked up yet
' PDFNoFontEmbedding - Do not Embed fonts in PDF. Set to 1 to stop the
' default process of embedding all fonts in the output PDF. If you are
' using ONLY - any of the standard Windows fonts
' using ONLY - any of the standard 14 Fonts natively supported by the PDF spec
'The 14 Standard Fonts
'All version of Adobe's Acrobat support 14 standard fonts. These fonts are
always available
'independent whether they're embedded or not.
'Family name PostScript name Style
'Courier Courier fsNone
'Courier Courier-Bold fsBold
'Courier Courier-Oblique fsItalic
'Courier Courier-BoldOblique fsBold + fsItalic
'Helvetica Helvetica fsNone
'Helvetica Helvetica-Bold fsBold
'Helvetica Helvetica-Oblique fsItalic
'Helvetica Helvetica-BoldOblique fsBold + fsItalic
'Times Times-Roman fsNone
'Times Times-Bold fsBold
'Times Times-Italic fsItalic
'Times Times-BoldItalic fsBold + fsItalic
'Symbol Symbol fsNone, other styles are emulated only
'ZapfDingbats ZapfDingbats fsNone, other styles are emulated only
' You must pass either RptName or SnapshotName or set the ShowSaveFileDialog
param to TRUE.
' Any file names you pass to this function must include the full path. If
you only include the
' filename for the output PDF then your document will be saved to your My
Documents folder.
Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this example.
blRet = ConvertReportToPDF(, "c:\windows\SOXReports\" & strApprover &
".snp", _
"c:\windows\SOXReports\" & strApprover & ".pdf", False, False, 0, "", "", 0,
0)
' To modify the above call to force the File Save Dialog to select the name
and path
' for the saved PDF file simply change the ShowSaveFileDialog param to TRUE.
End With
rs.MoveNext
Loop
End Sub
I would appreciate your insight.