Combine 3 PDF Files as per the Excel Sheet and path provided in it.

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,File Name 2 and File Name 3 and give the Output in the Final Folder with the Given output name.

File Name1File Name2File Name 3Output
C:/Home/1.pdfC:/Office/2.pdfC:/Office/3.pdfC:/Final/1&2&3.PDF
C:/Home/4.pdfC:/Office/5.pdfC:/Office/6.pdfC:/Final/4&5&6.PDF
C:/Home/7.pdfC:/Office/8.pdfC:/Office/9.pdfC:/Final/7&8&9.PDF
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Currently i know to Add Two Columns but unable to edit to add third column Please can someone help.

Public Sub Merge_PDFs()

Dim PDFfiles As Variant
Dim i As Long
Dim objCAcroPDDocDestination As Acrobat.CAcroPDDoc
Dim objCAcroPDDocSource As Acrobat.CAcroPDDoc

With ActiveSheet
PDFfiles = .Range("A2", .Cells(.Rows.Count, "C").End(xlUp)).Value
End With

'Create Acrobat API objects

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

'Loop through rows, open PDF file in column A, open and insert PDF file in column B, save as PDF file in column C

For i = 1 To UBound(PDFfiles)
objCAcroPDDocDestination.Open PDFfiles(i, 1)
objCAcroPDDocSource.Open PDFfiles(i, 2)
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, 2), vbExclamation
End If
objCAcroPDDocSource.Close
objCAcroPDDocDestination.Save 1, PDFfiles(i, 3)
objCAcroPDDocDestination.Close
Next

Set objCAcroPDDocSource = Nothing
Set objCAcroPDDocDestination = Nothing

MsgBox "Done"

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,264
Messages
6,123,960
Members
449,135
Latest member
jcschafer209

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