Access: Desire simple, clear code example for merging files
Posted: Tue Mar 24, 2015 3:06 pm
I desire a simple, clear, concise code vba code example that I can plug into an Access database for merging multiple .pdf files.
So if I have the following:
c:\test\report1.pdf
c:\test\report2.pdf
c:\test\report3.pdf
c:\test\report4.pdf
c:\test\report5.pdf
c:\test\report6.pdf
And I desire these to be merged into:
c:\test\FinalReport.pdf
How do I accomplish this in an Access VBA Code Module? I banged my head on this website and the internet in general attempting to accomplish with Bullzip to no avail.
I accomplished this using PDF Redirect but I had to research and purchase and educate myself on that code because Bullzip and the Bullzip forum does not provide clear and concise code example. This is how I accomplished it using the above software and I consider this to be clear and concise. PLEASE SUPPLY SOMETHING SIMILAR ON YOUR SITE.
Run this from a debug window:
subMerge 6, "c:\test\"
Public Sub subMerge(reportcount as integer, strPath as string)
'note: assumes 'PDF redirect Pro Remote Control' is installed as a library in Tools/References
'note: you might use docmd.outputto... code to send reports to desired locations as .pdf files prior to running this code
Dim oPDF As New PDF_reDirect_v25002.Batch_RC_AXD
Dim Files_to_Merge(200) As String
Dim TempBool As Boolean
For j = 1 To reportcount
If (LenB(strPath & "tempPdf" & j & ".pdf") > 0) Then
Files_to_Merge(j) = strPath & "tempPdf" & j & ".pdf"
End If
Next j
TempBool = oPDF.Utility_Merge_PDF_Files(strPath & strFileName, Files_to_Merge)
If Not TempBool Then
' NOTES ON ERROR CODES for oPDF.ErrorLastDLL
' 401 - One of the Input File could not be opened
' 410 - One of the Input File could not be decrypted
MsgBox "An Error Occured: " & oPDF.LastErrorDescription & vbCrLf & _
"Error Number =" & Str$(oPDF.LastErrorNumber) & vbCrLf & _
"DLL Error Number =" & Str$(oPDF.ErrorLastDLL), _
vbExclamation
End If
Set oPDF = Nothing
End Sub
So if I have the following:
c:\test\report1.pdf
c:\test\report2.pdf
c:\test\report3.pdf
c:\test\report4.pdf
c:\test\report5.pdf
c:\test\report6.pdf
And I desire these to be merged into:
c:\test\FinalReport.pdf
How do I accomplish this in an Access VBA Code Module? I banged my head on this website and the internet in general attempting to accomplish with Bullzip to no avail.
I accomplished this using PDF Redirect but I had to research and purchase and educate myself on that code because Bullzip and the Bullzip forum does not provide clear and concise code example. This is how I accomplished it using the above software and I consider this to be clear and concise. PLEASE SUPPLY SOMETHING SIMILAR ON YOUR SITE.
Run this from a debug window:
subMerge 6, "c:\test\"
Public Sub subMerge(reportcount as integer, strPath as string)
'note: assumes 'PDF redirect Pro Remote Control' is installed as a library in Tools/References
'note: you might use docmd.outputto... code to send reports to desired locations as .pdf files prior to running this code
Dim oPDF As New PDF_reDirect_v25002.Batch_RC_AXD
Dim Files_to_Merge(200) As String
Dim TempBool As Boolean
For j = 1 To reportcount
If (LenB(strPath & "tempPdf" & j & ".pdf") > 0) Then
Files_to_Merge(j) = strPath & "tempPdf" & j & ".pdf"
End If
Next j
TempBool = oPDF.Utility_Merge_PDF_Files(strPath & strFileName, Files_to_Merge)
If Not TempBool Then
' NOTES ON ERROR CODES for oPDF.ErrorLastDLL
' 401 - One of the Input File could not be opened
' 410 - One of the Input File could not be decrypted
MsgBox "An Error Occured: " & oPDF.LastErrorDescription & vbCrLf & _
"Error Number =" & Str$(oPDF.LastErrorNumber) & vbCrLf & _
"DLL Error Number =" & Str$(oPDF.ErrorLastDLL), _
vbExclamation
End If
Set oPDF = Nothing
End Sub