Merge PDF documents and save with a new name as per Excel Sheet

abdulads

Board Regular
Joined
Dec 22, 2013
Messages
81
Hi, Please help me Merge PDF Documents as per the Excel Sheet and path provided in it.

Here we have to combine File Name 1 and File Name 2 and give the Output in the Final Folder with the Given output name.

File Name1​
File Name2​
Output​
C:/Home/1.pdf​
C:/Office/2.pdf​
C:/Final/1&2.PDF​
C:/Home/3.pdf​
C:/Office/4pdf​
C:/Final/3&4.PDF​
C:/Home/5.pdf​
C:/Office/6.pdf​
C:/Final/5&6.PDF​
 
Hi I am wondering how would I make the above apply to merging 4 pdfs. I cannot seem to figure out the changes required to amend it correctly.
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Following the same cells layout as the OP, but with the 4 input PDF file names in columns A:D and the output PDF file name in column E, change the loop to:
VBA Code:
    Dim c As Long
    For i = 1 To UBound(PDFfiles)
        objCAcroPDDocDestination.Open PDFfiles(i, 1)
        For c = 2 To 4
            objCAcroPDDocSource.Open PDFfiles(i, c)
            If Not objCAcroPDDocDestination.InsertPages(objCAcroPDDocDestination.GetNumPages - 1, objCAcroPDDocSource, 0, objCAcroPDDocSource.GetNumPages, 0) Then
                MsgBox "Error merging" & vbCrLf & PDFfiles(i, 1) & vbCrLf & "and" & vbCrLf & PDFfiles(i, c), vbExclamation
            End If
            objCAcroPDDocSource.Close
        Next
        objCAcroPDDocDestination.Save 1, PDFfiles(i, c)
        objCAcroPDDocDestination.Close
    Next
However, please start a new thread if the way you specify the PDFs is different to the OP.
 
Upvote 0
Following the same cells layout as the OP, but with the 4 input PDF file names in columns A:D and the output PDF file name in column E, change the loop to:
VBA Code:
    Dim c As Long
    For i = 1 To UBound(PDFfiles)
        objCAcroPDDocDestination.Open PDFfiles(i, 1)
        For c = 2 To 4
            objCAcroPDDocSource.Open PDFfiles(i, c)
            If Not objCAcroPDDocDestination.InsertPages(objCAcroPDDocDestination.GetNumPages - 1, objCAcroPDDocSource, 0, objCAcroPDDocSource.GetNumPages, 0) Then
                MsgBox "Error merging" & vbCrLf & PDFfiles(i, 1) & vbCrLf & "and" & vbCrLf & PDFfiles(i, c), vbExclamation
            End If
            objCAcroPDDocSource.Close
        Next
        objCAcroPDDocDestination.Save 1, PDFfiles(i, c)
        objCAcroPDDocDestination.Close
    Next
However, please start a new thread if the way you specify the PDFs is different to the OP.
Hi @John_w it now wont merge the files at all the error merging message appears. I have specified my pdfs the same as the OP.
 
Upvote 0
Hi All,

I only have bluebeam software install on my PC. Anyone know how to use Revu Bluebeam API Object instead of Acrobat.
'Create Acrobat API objects

Set objCAcroPDDocDestination = CreateObject("AcroExch.PDDoc")
Set objCAcroPDDocSource = CreateObject("AcroExch.PDDoc")

Thank you.
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,011
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top