Help with merging PDF Files

  • Thread starter SteveAman via AccessMonster.com
  • Start date
S

SteveAman via AccessMonster.com

I have an MSACCESS-2007 App that created pages(Access Reports) of a parts
catalog and outputs them to pdf files numerically/sequentially named 1.pdf, 2.
pdf,3.pdf etc and all the way up to 1140.pdf.

All I want to do is to merge all these pdf filess(In order) into 1 PDF file
called Catalog.PDF

1.pdf is page 1, 2.pdf is page 2 etc.

I have tried PDFactiveX
***
Dim opdfActiveX As PDFActiveX.CreatePDF
strPDF = path & "\Catalog.pdf"
DOCDEST_FOLDER = "C:\Catalog"

opdfActiveX.CreatePDFfromMultiPDFinDir strPDF, DOCDEST_FOLDER2, "*.pdf",
pdoSortByName, pdoSortOrderAscending
****
but I keep getting "Object variable or With block Variable not set" error.
I have the pDFActiveX loaded as a reference(pdfx.dll)

Can somebody help.
 
J

Jack Leach

I'm not sure how to do this using the functionality provided by 2007 or any
activeX controls, but Stephen Lebans, as part of his ReportToPDF modules,
offers a dll called StrStorage.dll with a function you can declare (without
adding to references, just put StrStorage.dll in your apps root folder) to
merge pdfs...

dll can be downloaded here...
http://www.lebans.com/reporttopdf.htm



Option Compare Database
Option Explicit


Private Declare Function MergePDFDocuments _
Lib "StrStorage.dll" _
(ByVal PDFMaster As String, _
ByVal PDFChild As String _
) As Long


'==============================================================================
' NAME: MergePDFs
' DESC
'==============================================================================
'ErrStrV3.00
Public Function MergePDFs( _
sMasterFile As String, _
sChildFile As String _
)
On Error GoTo Error_Proc
'=========================

'=========================

MergePDFDocuments sMasterFile, sChildFile

'=========================
Exit_Proc:
Exit Function
Error_Proc:
MsgBox "Error: " & Trim(Str(Err.Number)) & vbCrLf & _
"Desc: " & Err.Description & vbCrLf & vbCrLf & _
"Module: modPDFUtils, Procedure: MergePDFs" _
, vbCritical, "Error!"
Resume Exit_Proc
Resume
End Function



hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
T

tighe

Steve,

first i want to give credit to whoever i puled and borrowed al the bits for
this:

Function PDF_Combine_B()
Dim AcroExchApp As Acrobat.CAcroApp
Dim AcroExchPDDoc As Acrobat.CAcroPDDoc
Dim AcroExchInsertPDDoc As Acrobat.CAcroPDDoc
Dim strFileName As String, strPath As String
Dim iNumberOfPagesToInsert As Integer
Dim iLastPage As Integer

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")

strFileName = "G:\cmcdb\20080922_CMCDB2\Documents\CE_Survey.pdf" 'Starting
file
AcroExchPDDoc.Open (strFileName)

Do While (isCount() > [Forms]![CE_Appendix_Create_b].CurrentRecord Or
isCount() = [Forms]![CE_Appendix_Create_b].CurrentRecord) ' i loop through a
form to know what pdfs are there to be added
iLastPage = AcroExchPDDoc.GetNumPages - 1
PageNum = [Forms]![CE_Appendix_Create_b].CurrentRecord
Set AcroExchInsertPDDoc = CreateObject("AcroExch.PDDoc")

AcroExchInsertPDDoc.Open
([Forms]![CE_Appendix_Create_b].[Summary]) ' file name
iNumberOfPagesToInsert = AcroExchInsertPDDoc.GetNumPages

AcroExchPDDoc.InsertPages iLastPage, AcroExchInsertPDDoc, 0,
iNumberOfPagesToInsert, 0
AcroExchInsertPDDoc.Close

If (isCount() > [Forms]![CE_Appendix_Create_b].CurrentRecord) Then

DoCmd.GoToRecord acForm, "CE_Appendix_Create_b", acNext 'goes to next record
which will contain the file name of the next pdf to insert
Sleep
(3000)
Else:
GoTo PDF_Combine_Exit
End If
Loop
PDF_Combine_Exit:
AcroExchPDDoc.Save 1, "G:\cmcdb\Employees\" &
[Forms]![001_Start]![consultant_ini] & "\Appendix_Full.pdf" 'save the
combined file

AcroExchApp.Exit
Exit Function
End Function


i'm sure you could parse through and tell it how to know what insert
differently but the basic idea is there, hope this helps. iam running
AC2007, XP, With Adobe 8.0 browser Control type library 1.0 and Adobe Acrobat
8.0 Type library. Installed is adobe 8 Professional.
 

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