Skip to main content

How to split a Word document into separate files every 5 or n pages?

Author Xiaoyang Last modified

When working with large Word documents, you may need to split the document into smaller, separate files for easier handling, sharing, or editing. Splitting a document every 5 or 10 or a specified number of pages can be a practical solution for managing lengthy content more efficiently.

Manually copying and pasting pages one by one is time-consuming and inefficient. In this tutorial, we will introduce quick and easy methods to split a Word document into separate files every N pages:

Split a Word document into separate files every N pages with VBA code

Split a Word document into separate files every N pages with an amazing feature


Split a Word document into separate files every N pages with VBA code

To split a large document into separate files based on every N pages, the following VBA code can assist you. Follow these steps:

  1. Hold down ALT + F11 to open the Microsoft Visual Basic for Applications window.
  2. Click Insert > Module, and copy and paste the following code into the blank module:
  3. Sub DocumentSplitter()
        Dim xDoc As Document, xNewDoc As Document
        Dim xSplit As String, xCount As Long, xLast As Long
        Dim xRngSplit As Range, xDocName As String, xFileExt As String
        Dim xRegEx As RegExp
        Dim xPageCount As Integer
        Dim xShell As Object, xFolder As Object, xFolderItem As Object
        Dim xFilePath As String
        On Error Resume Next
        Set xDoc = Application.ActiveDocument
        Set xShell = CreateObject("Shell.Application")
        Set xFolder = xShell.BrowseforFolder(0, "Select a Folder:", 0, 0)
        If TypeName(xFolder) = "Nothing" Then Exit Sub
        Set xFolderItem = xFolder.Self
        xFilePath = xFolderItem.Path & "\"
        Application.ScreenUpdating = False
        Set xNewDoc = Documents.Add(Visible:=False)
        xDoc.Content.WholeStory
        xDoc.Content.Copy
        xNewDoc.Content.PasteAndFormat wdFormatOriginalFormatting
        With xNewDoc
            xPageCount = .ActiveWindow.Panes(1).Pages.Count
    L1:     xSplit = InputBox("The document contains " & xPageCount & " pages." & _
                     vbCrLf & vbCrLf & "Please enter the number of pages per split:", "Kutools for Word", xSplit)
            If Len(Trim(xSplit)) = 0 Then Exit Sub
            Set xRegEx = New RegExp
            With xRegEx
                .MultiLine = False
                .Global = True
                .IgnoreCase = True
                .Pattern = "[^0-9]"
            End With
            If xRegEx.Test(xSplit) = True Then
                MsgBox "Please enter a valid page number:", vbInformation, "Kutools for Word"
                Exit Sub
            End If
            If VBA.Int(xSplit) >= xPageCount Then
                MsgBox "The entered number exceeds the total page count of the document." & vbCrLf & "Please enter a valid number.", vbInformation, "Kutools for Word"
                GoTo L1
            End If
            xDocName = xDoc. Name
            xFileExt = VBA.Right(xDocName, Len(xDocName) - InStrRev(xDocName, ".") + 1)
            xDocName = Left(xDocName, InStrRev(xDocName, ".") - 1) & "_"
            xFilePath = xFilePath & xDocName
            For xCount = 0 To Int(xPageCount / xSplit)
                xPageCount = .ActiveWindow.Panes(1).Pages.Count
                If xPageCount > xSplit Then
                    xLast = xSplit
                Else
                    xLast = xPageCount
                End If
                Set xRngSplit = .GoTo(What:=wdGoToPage, Name:=xLast)
                Set xRngSplit = xRngSplit.GoTo(What:=wdGoToBookmark, Name:="\page")
                xRngSplit.Start = .Range.Start
                xRngSplit.Cut
                Documents.Add
                Selection.Paste
                ActiveDocument.SaveAs FileName:=xFilePath & xCount + 1 & xFileExt, AddToRecentFiles:=False
                ActiveWindow.Close
            Next xCount
            Set xRngSplit = Nothing
            xNewDoc.Close wdDoNotSaveChanges
            Set xNewDoc = Nothing
        End With
        Application.ScreenUpdating = True
    End Sub
  4. After pasting the code, still in the Microsoft Visual Basic for Applications window, click Tools > References. In the References - Project dialog box, check the Microsoft VBScript Regular Expressions 5.5 option from the Available References list. See screenshots:
    VBA window with Tools > References selected Arrow Microsoft VBScript Regular Expressions 5.5 checked in the References-Project dialog box
  5. Click OK, then press F5 to run the code.
  6. A Browse For Folder dialog box will appear. Select the folder where you want to save the split files, and click OK.
  7. Browse For Folder dialog box

  8. Another prompt will appear asking for the number of pages you want to split by. Enter the desired page count and click OK.
  9. Dialog box for entering the page number to split based on

  10. The document will be split into separate files every N pages. Navigate to the specified folder to view the results.
  11. The document is split into separate files every N pages


Split a Word document into separate files every N pages with an amazing feature

Kutools for Word provides a powerful Split function that enables you to quickly split a large Word document into multiple separate files based on Heading 1, page breaks, section breaks, or pages. This feature streamlines what would otherwise be a tedious manual process.

Kutools for Word, equipped with AI πŸ€–, offers over 100 handy features to simplify your tasks.
  1. Click Kutools Plus > Split.

    Split button on the Kutools tab on the ribbon

  2. In the dialog box that appears, configure the following options as needed:
    1. Select the Every n pages option from the Split by menu.
    2. Specify the n value in the input box.
    3. Choose a saving location.
    4. Specify a prefix for the split documents.

      Split Document dialog box

  3. After completing the settings, click OK. The document will be split into multiple files based on the selected option (e.g., every 7 pages).

    The document is split into separate files every N pages

Using the Split feature in Kutools for Word makes dividing large documents into smaller, manageable files both simple and efficient.

Kutools for Word is the ultimate Word add-in that streamlines your work and boosts your document processing skills. Get It Now!

Best Office Productivity Tools

Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!

πŸ€– Kutools AI Features: AI Assistant / Real-Time Assistant / Super Polish (Preserve Format) / Super Translate (Preserve Format) / AI Redaction / AI Proofread...

πŸ“˜ Document Mastery: Split Pages / Merge Documents / Export Selection in Various Formats (PDF/TXT/DOC/HTML...) / Batch Convert to PDF...

✏ Contents Editing: Batch Find and Replace across Multiple Files / Resize All Pictures / Transpose Table Rows and Columns / Convert Table to Text...

🧹 Effortless Clean: Sweap away Extra Spaces / Section Breaks / Text Boxes / Hyperlinks / For more removing tools, head to the Remove group...

βž• Creative Inserts: Insert Thousand Separators / Check Boxes / Radio Buttons / QR Code / Barcode / Multiple Pictures / Discover more in the Insert group...

πŸ” Precision Selections: Pinpoint Specific Pages / Tables / Shapes / Heading Paragraphs / Enhance navigation with more Select features...

⭐ Star Enhancements: Navigate to Any Location / Auto-Insert Repetitive Text / Toggle Between Document Windows / 11 Conversion Tools...

🌍 Supports 40+ Languages: Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Kutools and Kutools Plus tabs on the Word Ribbon
πŸ‘‰ Want to try these features? Download Kutools for Word now! πŸš€
 

Best Office Productivity Tools

Kutools for Word - 100+ Tools for Word