
-800x450.jpg)
- How to combine pdf files with foxit phantom code#
- How to combine pdf files with foxit phantom series#
XPath = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1) & "\" With Application.FileDialog(msoFileDialogFolderPicker) Sub FolderNames()ĭim fso As Object, j As Long, folder1 As Object
How to combine pdf files with foxit phantom code#
The below code i got from stack overflow this will list all sub folders in a folder. Set PdfSrc = CreateObject("AcroExch.PDDoc") Set PdfDst = CreateObject("AcroExch.PDDoc") No need to create the Vb Reference to the Adobe Library Sub PDFs_Combine_LateBound() MsgBox "Pdf files combined successfully!", vbExclamation MsgBox "Error saving combined pdf:" & vbCrLf _ If Not (.Save(PDSaveFull, sPdfComb)) Then MsgBox "Error inserting source pdf:" & vbCrLf _ GetNumPages, PdfSrc, 0, PdfSrc.GetNumPages, 0)) Then MsgBox "Error opening source pdf:" & vbCrLf _ If Dir(sPdf, vbArchive) = vbNullString Then Exit Do & vbCrLf & vbTab & "Procees will be cancelled!", vbCritical

MsgBox "Error opening destination pdf:" & vbCrLf _ SPdf = ThisWorkbook.Path & "\" & "firstpdf" & b & ".pdf" SPdfComb = ThisWorkbook.Path & "\" & "Pdf Combined" & Format(Now, " mmdd_hhmm ") & ".pdf" 'change as required Rem Set Combined Pdf filename - save the combined pdf in a new file in order to preserve original pdfs Sub PDFs_Combine_EarlyBound()ĭim PdfDst As AcroPDDoc, PdfSrc As AcroPDDoc To create the Vb Reference to the Adobe Library in the VBA Editor menu click Tools`References then select theAdobe Acrobat Library in the dialog window then press theOK` button. Solutions: These procedures use the Adobe Acrobat Library

How to combine pdf files with foxit phantom series#
Combined a series of pdf files, located in the same folder of the workbook containing the procedure.This is my understanding of your question: StrFile = Dir(inputDirectoryToScanForFile & "*.pdf")Ĭode that takes a primary file and inserts other pdfs into that file: Sub main()ĪrrayFilePaths = Array("C:\Users\Evan\Desktop\PAGE1.pdf", _ InputDirectoryToScanForFile = "C:\Users\Evan\Desktop\New Folder\" PrimaryFile = "C:\Users\Evan\Desktop\myPDf.Pdf" Sub main()ĭim inputDirectoryToScanForFile As String These are the pathways later used in the adobe API calls to insert pdf into your primary. The loop in this code will add the pathway of every pdf file in that folder to your collection. Then assign the folder pathway of the folder with the pdf files that you would like to see inserted into your primary doc to inputDirectoryToScanForFile. The first file in the collection would be the file that you are inserting into, same as in first example. You can use something like below to generate the collection of documents to be inserted into your primary doc. I used this resource re method referencesĮDIT: Swapping the array for auto generated (mostly, the primary pdf still set by user) list of pathways to pdfs that you want to insert into the primary pdf) You need to have adobe acrobat installed / operational. OK = primaryDoc.Save(PDSaveFull, arrayFilePaths(0))ĭebug.Print "PRIMARYDOC SAVED PROPERLY: " & OK OK = primaryDoc.InsertPages(numPages, sourceDoc, 0, numberOfPagesToInsert, False)ĭebug.Print "PAGES INSERTED SUCCESSFULLY: " & OK NumberOfPagesToInsert = sourceDoc.GetNumPages OK = sourceDoc.Open(arrayFilePaths(arrayIndex))ĭebug.Print "SOURCE DOC OPENED & PDDOC SET: " & OK Set sourceDoc = CreateObject("AcroExch.PDDoc") Set primaryDoc = CreateObject("AcroExch.PDDoc")ĭebug.Print "PRIMARY DOC OPENED & PDDOC SET: " & OKįor arrayIndex = 1 To UBound(arrayFilePaths) If objCAcroPDDocDestination.InsertPages(objCAcroPDDocDestination.GetNumPages - 1, objCAcroPDDocSource, 0, objCAcroPDDocSource.GetNumPages, 0) Then ObjCAcroPDDocSource.Open ThisWorkbook.Path & "pathwithpdfs" & PDFfileName 'Open the source document that will be added to the destination PDFfileName = Dir(ThisWorkbook.Path & "firstpdf" & n & ".pdf") I get no error msg but perhaps I am missing parts.Īny help would be appreciated. I have tried something like, but cannot seem to get it to work. I would like to not use a plug in tool and have tried with acrobat api below. I am trying to combine PDF's into one single pdf with the use of vba.
