ReportstoPDF - Multiple Pages

R

Rich

I've been searching for an answer all day but havn't had any luck.

I've built a VBA application that generates about 80 pages per set, and
there are 9 sets in total.

Currently i'm using Mr. Leban's ReportToPDF code that helps to automatically
generate the reports to PDF format. But now i'm left with 80 individual PDF
files per Set. Is there a way to put all 80 reports into one PDF file via
VBA code?

Any help would be greatly appreciated.

Thanks,

Rich
 
R

Rich

I've figured it out.

I went to the adobe website and downloaded their free API.

I then included the reference to it in my project then used the following
function:

WARNING: This is quick and dirty code. It has not yet been streamlined to
perform at maximun efficiency and its very messy :p

Parameters:
masterPDF = the container PDF that all other PDFs will be inserted into
toAdd = Document that is to be added into masterPDF
path = The full path to where the documents are stored ie: "C:\Temp"

Function:
Private Function CombinePDF(masterPDF, toAdd, path) As Boolean

Dim b As Boolean
Dim AcroPDDoc As CAcroPDDoc
Dim PDDoc As CAcroPDDoc

Set AcroPDDoc = CreateObject("AcroExch.PDDoc")
Set PDDoc = CreateObject("AcroExch.PDDoc")
CombinePDF = True

b = PDDoc.Open(path & toAdd)
If b = False Then
MsgBox ("Error. could not open toAdd")
CombinePDF = False
Exit Function
End If

b = AcroPDDoc.Open(path & masterPDF)
If b = False Then
MsgBox ("Error. could not open masterPDF")
CombinePDF = False
Exit Function
End If

b = AcroPDDoc.InsertPages(AcroPDDoc.GetNumPages - 1, PDDoc, 0, 1, False)
If b = False Then
MsgBox ("Error. could not InsertPages")
CombinePDF = False
Exit Function
End If

b = AcroPDDoc.Save(1, path & masterPDF)
If b = False Then
MsgBox ("Error. could not save")
CombinePDF = False
Exit Function
End If

End Function

Use:
So, after i generate the report using ReportToPDF, i call this function and
it combines it with masterPDF.
path and masterPDF are pre-set before generating the other reports that are
combined with master and toAdd is generated on the fly.

A little research goes a long way :)

Hope this is helpful for someone else in the future.



Rich
 

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