How to Split a PDF into Separate Files Using Excel VBA
Question details
The user needs to divide a variable-length PDF into multiple distinct files based on specific text or room information, such as Room 101 or Room 105.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Organizing and distributing specific sections of a large PDF report to different recipients based on room numbers contained within the text.
- Observed behavior
- Excel does not have a built-in feature to split PDFs by text, requiring custom VBA macros or external assistance to parse the data and extract page ranges.
Ensure you have the target PDF file saved locally and that macros are enabled in your Excel workbook if you plan to use a VBA script. Identifying the exact page ranges for each room beforehand will make the splitting process much smoother.
Use a Custom Excel VBA Macro to Split PDFs
Write and execute a VBA script to automate the process of reading PDF page ranges and extracting them into new files.
Excel does not natively support splitting PDF files based on text content. However, by leveraging VBA (Visual Basic for Applications) and connecting it to a PDF application's API, you can automate the extraction of specific pages into separate files based on your spreadsheet data.
Launch Excel and press 'Alt + F11' to open the Visual Basic for Applications Editor.
Click on 'Insert' in the top menu and select 'Module' to create a blank canvas for your script.
Write or paste a VBA script that references your installed PDF software's API to loop through the document and extract pages based on the room variables. You may need to consult the Microsoft Docs community for specific code snippets compatible with your PDF software.
Press 'F5' or click 'Run' to execute the macro, which will generate the separated PDF files in your specified directory.
Manually Extract Pages Using a PDF Editor
A simpler approach for users without programming experience is to use a dedicated PDF editor to locate and extract pages manually.
Split and Manage PDFs Effortlessly with WPS Office
Instead of writing complex VBA code in Excel to divide your documents, you can use the built-in WPS PDF tool to easily split, extract, and organize your PDF pages in just a few clicks.
- 1. Open the PDF in WPS: Launch WPS Office and open your large PDF file containing the room information.
- 2. Navigate to the Page Tab: Click on the 'Page' tab located on the top toolbar to access page management features.
- 3. Select Split PDF: Click on the 'Split PDF' button. A dialog box will appear allowing you to customize how the document is divided.
- 4. Set Page Ranges: Choose to split the document by specific custom page ranges that correspond to your room data.
- 5. Save Separate Files: Select your output folder and click 'Split' to instantly generate and save the separate PDF documents.

Frequently Asked Questions
Can I split a PDF in Excel without using VBA?
No, Excel is primarily a spreadsheet application and does not have native tools to view, edit, or split PDF files. You must either use VBA to automate a third-party PDF tool or use a dedicated PDF editor directly.
Is it possible to automatically split a PDF based on specific text?
Yes, but it requires advanced PDF software with bookmark-splitting capabilities or custom scripts (like Python or advanced VBA) that can parse the text content of the PDF and trigger a split operation when a specific keyword is found.
Why doesn't my VBA code to split PDFs work on my computer?
VBA scripts for splitting PDFs usually rely on an external PDF application's API. If that specific software is not installed on your machine, or the proper object reference library is not enabled in the VBA editor, the macro will fail to execute.





