Split a Word Document into Six-Page Files with VBA
Question details
Automatically divide a large Word document into separate files containing up to six pages each.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A single Word file contains multiple six-page sets that need to be saved as individual documents.
- Observed behavior
- A previous macro attempt produced error 91, and creating the files manually would be time-consuming.
Open the document in desktop Word and save a copy to a local folder. Check its page layout and page count before splitting; pagination can change when content is placed in a new document.
Run a VBA macro to save six-page ranges as separate files
Use this Windows desktop Word macro to create files from consecutive six-page ranges without cutting content from the source.
The macro calculates page boundaries in the source document and copies each range into a new document. The last file may contain fewer than six pages.
New documents can reflow differently from the source. Headers, footers, floating objects, section formatting, and blank pages may not transfer as expected, so review each output file.
In Word, open the locally saved document to split. Press Alt+F11, then select Insert > Module.
Paste this code into the module: Sub SplitEverySixPages() Dim src As Document, dst As Document Dim pageStart As Range, nextStart As Range Dim totalPages As Long, firstPage As Long Dim startPos As Long, endPos As Long, fileNumber As Long Dim outputPath As String, filePrefix As String Set src = ActiveDocument If src.Path = "" Then MsgBox "Save the source document to a local folder first." Exit Sub End If src.Repaginate totalPages = src.ComputeStatistics(wdStatisticPages) filePrefix = src.Path & "\Split_" & Format(Now, "yyyymmdd_hhnnss") & "_" fileNumber = 1 For firstPage = 1 To totalPages Step 6 Set pageStart = src.GoTo(What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=firstPage) startPos = pageStart.Start If firstPage + 6 <= totalPages Then Set nextStart = src.GoTo(What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=firstPage + 6) endPos = nextStart.Start Else endPos = src.Content.End End If outputPath = filePrefix & Format(fileNumber, "000") & ".docx" If Dir(outputPath) <> "" Then MsgBox "Output file already exists: " & outputPath Exit Sub End If Set dst = Documents.Add dst.Content.FormattedText = src.Range(Start:=startPos, End:=endPos).FormattedText dst.SaveAs2 FileName:=outputPath, FileFormat:=wdFormatXMLDocument dst.Close SaveChanges:=wdDoNotSaveChanges fileNumber = fileNumber + 1 Next firstPage MsgBox "Created " & (fileNumber - 1) & " files in " & src.Path End Sub
Return to Word, keep the source document active, and select Developer > Macros. Choose SplitEverySixPages and select Run. Enable macros only if you trust the code.
Open the new Split_ files in the source document's folder. Check their page counts, content, headers, footers, and layout against the corresponding source pages.

Review split Word files with WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface for opening and reviewing Word documents. Its format compatibility makes it easy to move existing files over, although it does not fix or guarantee compatibility with Microsoft Word VBA macros.

Frequently Asked Questions
What happens if the document has fewer than six pages left?
The macro saves the remaining pages in a final DOCX file; it does not require the total page count to be divisible by six.
Why does a split file have a different page count?
The new document may use different page settings or reflow content. Open each output file and compare its layout and content with the source, especially around section breaks and floating objects.
Where are the split files saved?
The macro saves them in the source document's local folder, using a timestamp and sequential number in each filename.
How do I fix VBA error 91?
Error 91 indicates that an object variable has not been set. In the VBA editor, check that each Document or Range variable is assigned with Set before it is used.
Can I run this macro in Word for the web?
No. Open the document in desktop Word to use the VBA editor and run the macro.




