T
TerryC
Dear All,
I have an application that generates individual PDFs (for
each record) from a report. I am using an Access library
purchased from a third party to generate the PDFs using
Acrobat 6.01.
My two problems are "it is slow going" and after about 500-
700 records Access dies and wants to send an error report
to MS. It repairs and compact OK (for another 500 or so
records). The lack of any error code or indication of what
is causing this is frustrating.
I have to generate 10,000 - 30,000 pdfs per month and not
being able to rely on Access to keep running means it can
not be left over night.
I am currenly able to generate about 7 PDFs per minute (in
between crashes). I have posted the code I use below. I am
not an experienced (or very good) coder so I am hopefull
someone can see something stupid I've done that can be
fixt.
==================================================
Dim SavePath As String
SavePath = Forms!Print.Text0
Dim response
With Application.FileSearch
.LookIn = SavePath
.SearchSubFolders = False
.FileName = "*.pdf"
If .Execute() > 0 Then
GoTo cont
Else
MsgBox "There were no files found."
GoTo cont2
End If
cont:
response = MsgBox("There were " & .FoundFiles.Count & _
" file(s) found. Proceed?", 4)
If response = vbYes Then
GoTo cont2
Else: GoTo end_pdf
End If
End With
cont2:
Dim objPDF As New PDFClass
Dim lngResult As Long
Dim oput As String
Dim rpt As String
Dim memb As String
Dim ref As String
Dim strt As Long
Dim conn As ADODB.Connection
Dim rsPDF As New ADODB.Recordset
Dim strCnn As String
Dim RecNo As Long
RecNo = Forms!Print.Text2 'starting record number
strt = Forms!Print.Text2
' Open connection.
Set conn = CurrentProject.Connection
' Open pdf source records
Set rsPDF = New ADODB.Recordset
rsPDF.Open "tax_lhc_members", conn, , , adCmdTable
rsPDF.MoveFirst ' go to first record
rsPDF.Move strt - 1 ' starts from record # on form
print
Do While RecNo - 1 < Forms!Print.Text4 ' loop till end
of file
ref = rsPDF![extra 10]
memb = rsPDF![extra 10] & ".pdf"
oput = SavePath & memb
rpt = "LHCtax_only_pdf"
Const PDFENGINE_PDFWRITER = 1 ' not sure ... does
something?
With objPDF ' creates the pdf
.PDFEngine = PDFENGINE_PDFWRITER
.ReportName = rpt
.ReportWhere = "cstr([extra 10]) = " & ref
.OutputFile = oput
.PrintImage
lngResult = .Result
End With
rsPDF.MoveNext
RecNo = RecNo + 1
Loop
Set objPDF = Nothing
Set rsPDF = Nothing
end_pdf:
=================================================
Any suggestions, ideas or anything will be greatly
appreciated,
Terry
I have an application that generates individual PDFs (for
each record) from a report. I am using an Access library
purchased from a third party to generate the PDFs using
Acrobat 6.01.
My two problems are "it is slow going" and after about 500-
700 records Access dies and wants to send an error report
to MS. It repairs and compact OK (for another 500 or so
records). The lack of any error code or indication of what
is causing this is frustrating.
I have to generate 10,000 - 30,000 pdfs per month and not
being able to rely on Access to keep running means it can
not be left over night.
I am currenly able to generate about 7 PDFs per minute (in
between crashes). I have posted the code I use below. I am
not an experienced (or very good) coder so I am hopefull
someone can see something stupid I've done that can be
fixt.
==================================================
Dim SavePath As String
SavePath = Forms!Print.Text0
Dim response
With Application.FileSearch
.LookIn = SavePath
.SearchSubFolders = False
.FileName = "*.pdf"
If .Execute() > 0 Then
GoTo cont
Else
MsgBox "There were no files found."
GoTo cont2
End If
cont:
response = MsgBox("There were " & .FoundFiles.Count & _
" file(s) found. Proceed?", 4)
If response = vbYes Then
GoTo cont2
Else: GoTo end_pdf
End If
End With
cont2:
Dim objPDF As New PDFClass
Dim lngResult As Long
Dim oput As String
Dim rpt As String
Dim memb As String
Dim ref As String
Dim strt As Long
Dim conn As ADODB.Connection
Dim rsPDF As New ADODB.Recordset
Dim strCnn As String
Dim RecNo As Long
RecNo = Forms!Print.Text2 'starting record number
strt = Forms!Print.Text2
' Open connection.
Set conn = CurrentProject.Connection
' Open pdf source records
Set rsPDF = New ADODB.Recordset
rsPDF.Open "tax_lhc_members", conn, , , adCmdTable
rsPDF.MoveFirst ' go to first record
rsPDF.Move strt - 1 ' starts from record # on form
Do While RecNo - 1 < Forms!Print.Text4 ' loop till end
of file
ref = rsPDF![extra 10]
memb = rsPDF![extra 10] & ".pdf"
oput = SavePath & memb
rpt = "LHCtax_only_pdf"
Const PDFENGINE_PDFWRITER = 1 ' not sure ... does
something?
With objPDF ' creates the pdf
.PDFEngine = PDFENGINE_PDFWRITER
.ReportName = rpt
.ReportWhere = "cstr([extra 10]) = " & ref
.OutputFile = oput
.PrintImage
lngResult = .Result
End With
rsPDF.MoveNext
RecNo = RecNo + 1
Loop
Set objPDF = Nothing
Set rsPDF = Nothing
end_pdf:
=================================================
Any suggestions, ideas or anything will be greatly
appreciated,
Terry