How to Automate Splitting Word Documents by Heading 1 into HTML
Question details
The user needs an automated method to split large numbers of Word documents into separate sections based on Heading 1 styles and save each section as a filtered HTML file.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Processing hundreds of large documents containing multiple sections that need to be published or saved as individual web pages without manual copying and pasting.
- Observed behavior
- Manually creating subdocuments and exporting them individually is highly time-consuming and inefficient for large batches of files.
Ensure you have enabled the Developer tab in your word processor to access VBA features, and always create a backup copy of your original documents before running any automated batch-processing scripts.
Use a VBA Macro to Split Documents and Export to HTML
Running a custom VBA macro is the most direct way to automate splitting documents based on specific heading styles and saving them as filtered HTML.
A well-written VBA script can loop through your entire document, identify every instance of a Heading 1, copy the content until the next heading, and save it as a new HTML file. This eliminates the need for manual extraction.
Press Alt + F11 in your word processor to open the Visual Basic for Applications (VBA) editor.
Click on 'Insert' in the top menu and select 'Module'. Paste your document-splitting macro code into the blank window.
Ensure the script is configured to search for the 'Heading 1' style and sets the output format to 'wdFormatFilteredHTML'.
Press F5 or click the 'Run' button. The script will automatically parse the document and generate the split HTML files in your designated local folder.

Utilize a Document Batch-Processing Add-in
If you prefer not to write or handle VBA code, third-party add-ins can process and split documents automatically through a user-friendly interface.
Looking for a Lightweight Word Processor? Try WPS Office
While specific third-party batch-processing add-ins for VBA automation are native to Microsoft Word, WPS Office provides a fantastic, free, and lightweight alternative for your daily document editing, structuring, and exporting needs. Experience high compatibility without the heavy subscription fees.
- 1. Download and Install WPS Office: Get the free version of WPS Office from the official website and install it on your device.
- 2. Open Your Word Documents: Launch WPS Writer and seamlessly open your existing Microsoft Word documents with perfect formatting retention.
- 3. Manage Headings and Export: Use the Navigation Pane to easily view and manage your Heading 1 structures, and utilize the 'Save As' feature to export sections to HTML web pages.

Frequently Asked Questions
What does 'Filtered HTML' mean when saving a Word document?
Filtered HTML removes Microsoft Office-specific formatting tags and metadata, resulting in cleaner, smaller code that loads faster on web browsers and is easier to integrate into websites.
Can I split documents based on Heading 2 instead?
Yes. If you are using a VBA macro or a batch-processing add-in, you can modify the target style parameter in the code or the settings menu from 'Heading 1' to 'Heading 2'.
Why is my macro not running when I press Alt + F11?
Your word processor's macro security settings may be set to 'Disable all macros without notification.' You will need to change this setting in the Trust Center or Developer options to allow custom macros to run.
Can I automate this process without downloading third-party add-ins?
Yes, by exclusively using a VBA script (Macro) written specifically for your word processor, you can achieve the exact same automated splitting and HTML saving without needing external add-ins.




