Sub SplitPDFtk()
'https://www.mrexcel.com/board/threads/split-pdf-using-excel-vba.1225438/
Dim SourceFile As String, DestFile As String
Dim strParam As String, RetVal As String, PDFtk As String
Dim i As Integer
PDFtk = "C:\PortableApps\PDFTKBuilderPortable\App\pdftkbuilder\pdftk.exe " '<<===== ADJUST the Path
SourceFile = "C:\Users\Sequoyah\Desktop\Forum\Foxtrot.pdf" '<<===== ADJUST the Path and the source File name
Application.ScreenUpdating = False
For i = 1 To 20
DestFile = "C:\Users\Sequoyah\Desktop\Forum\" & "10" & Format(i, "00") & ".pdf" ''<<===== ADJUST the Path
strParam = SourceFile & " cat " & i & "-" & i & " output " & DestFile
RetVal = Shell(PDFtk & strParam, 0)
Next i
Application.ScreenUpdating = True
MsgBox "Done.", vbInformation
End Sub
Hi, can you tell me in case I have so many files to split, And I call the part file in column A, and want to split the file by each part file in that column A, how do I edit this code? . (I wrote the code that calls the part file from the directory) but I still don't know how to edit the above code so that it runs separate file by part file in column A. Can you help me with this?Hi Shinod
you can't handle PDF file with VBA alone, you need third party software. Here's an example using PDFTK Builder Enhanced Portable, you can find it here
PDFTK Builder Enhanced Portable (split, collate, watermark and password protect PDF documents) | PortableApps.com
PDFTK Builder is a pdf manipulation utility for Windows with a great array of features including: Collate - allows you to rearrange (reorder, delete, & duplicate) pages in a single document and/or merge pages from multiple PDF documents. Split - allows you to separate each page of a PDF document...portableapps.comVBA Code:Sub SplitPDFtk() 'https://www.mrexcel.com/board/threads/split-pdf-using-excel-vba.1225438/ Dim SourceFile As String, DestFile As String Dim strParam As String, RetVal As String, PDFtk As String Dim i As Integer PDFtk = "C:\PortableApps\PDFTKBuilderPortable\App\pdftkbuilder\pdftk.exe " '<<===== ADJUST the Path SourceFile = "C:\Users\Sequoyah\Desktop\Forum\Foxtrot.pdf" '<<===== ADJUST the Path and the source File name Application.ScreenUpdating = False For i = 1 To 20 DestFile = "C:\Users\Sequoyah\Desktop\Forum\" & "10" & Format(i, "00") & ".pdf" ''<<===== ADJUST the Path strParam = SourceFile & " cat " & i & "-" & i & " output " & DestFile RetVal = Shell(PDFtk & strParam, 0) Next i Application.ScreenUpdating = True MsgBox "Done.", vbInformation End Sub