# Split PDF Using Excel VBA



## Shinod (Dec 26, 2022)

Dear Excel VBA Experts,

I have a pdf file with 20 Pages. Is there any Excel VBA to split each page and rename each page starting from 1001 and ending 1020?

Thanks in Advance


----------



## Sequoyah (Dec 26, 2022)

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.com
				




```
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
```


----------

