GirishDhruva
Active Member
- Joined
- Mar 26, 2019
- Messages
- 308
Hi Everyone,
Here i am trying to combine two PDF sheets using Adobe, where the below code runs perfectly but
but can anyone suggest me how i can combine two PDF sheets and save that sheet in separate PDF file and in separate path
Is their any possible ways to do that?????
Please do suggest me with this
Regards
Dhruv
Here i am trying to combine two PDF sheets using Adobe, where the below code runs perfectly but
Code:
Sub Combine_PDF()
Dim x, lastrow As Long
Dim arrayFilePaths() As Variant
Set app = CreateObject("Acroexch.app")
lastrow = Sheets("Combine_PDF").Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To lastrow
path1 = Cells(x, "A").Value
path2 = Cells(x, "B").Value
arrayFilePaths = Array(path1, path2)
Set primaryDoc = CreateObject("AcroExch.PDDoc")
OK = primaryDoc.Open(arrayFilePaths(0))
Debug.Print "PRIMARY DOC OPENED & PDDOC SET: " & OK
For arrayIndex = 1 To UBound(arrayFilePaths)
numPages = primaryDoc.GetNumPages() - 1
Set sourceDoc = CreateObject("AcroExch.PDDoc")
OK = sourceDoc.Open(arrayFilePaths(arrayIndex))
Debug.Print "SOURCE DOC OPENED & PDDOC SET: " & OK
numberOfPagesToInsert = sourceDoc.GetNumPages
OK = primaryDoc.InsertPages(numPages, sourceDoc, 0, numberOfPagesToInsert, False)
Debug.Print "PAGES INSERTED SUCCESSFULLY: " & OK
OK = primaryDoc.Save(PDSaveFull, arrayFilePaths(0))
Debug.Print "PRIMARYDOC SAVED PROPERLY: " & OK
Set sourceDoc = Nothing
Next arrayIndex
Set primaryDoc = Nothing
Next x
app.Exit
Set app = Nothing
MsgBox "DONE"
End Sub
but can anyone suggest me how i can combine two PDF sheets and save that sheet in separate PDF file and in separate path
Is their any possible ways to do that?????
Please do suggest me with this
Regards
Dhruv
Last edited: