Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

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

If you have a large Word document which contains hundreds pages, and now, you would like to split this document into separate files every 10 or n pages. Is there any quick and easy way for solving this job without copying and pasting the pages one by one?

Split a Word document into separate files every 10 or n pages with VBA code

Split a Word document into separate files every 1 page with Kutools for Word


Split a Word document into separate files based on each page:

With Kutools for Word's Split feature, you can quickly split a large Word document into multiple separate files based on Heading1, page break, section break and page.

doc split word every n pages 9

Kutools for Word: with more than 100 handy Word add-ins, free to try with no limitation in 60 days. Click to Download and free trial Now!


Split a Word document into separate files every 10 or n pages with VBA code

To split a large document into separate files based on every 10 or n pages, the following VBA code can do you a favor, please do as this:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. And then, click Insert > Module, copy and paste below code into the opened blank module:

VBA code: Split a document into separate files every 10 or n pages:

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 page count you want to 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 the page number:", vbInformation, "Kutools for Word"
            Exit Sub
        End If
        If VBA.Int(xSplit) >= xPageCount Then
            MsgBox "The number is greater than the document number." & vbCrLf & "Please re-enter", 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

3. After pasting the above code, still in the Microsoft Visual Basic for Applications window, please click Tools > References, and in the popped out References-Project dialog box, check Microsoft VBScript Regular Expressions 5.5 option in the Available References list box, see screenshot:

doc split word every n pages 1

4. Then click OK button, and then press F5 key to run this code, and a Browse For Folder dialog box is displayed, please select a folder where you want to put the split files in, see screenshot:

doc split word every n pages 2

5. Then click OK button, and another prompt box is popped out to remind you entering the page count number that you want to split based on, see screenshot:

doc split word every n pages 3

6. And then click OK button, the active Word document has been split into separate files every 10 pages, you can go the specified folder to see the results:

doc split word every n pages 4


Split a Word document into separate files every 1 page with Kutools for Word

Kutools for Word includes a powerful feature- Split function, with this utility, you can quickly split a large Word document into multiple separate files based on Heading1, page break, section break and page.

Kutools for Word : with more than 100 handy Word add-ins, free to try with no limitation in 60 days. 

After installing Kutools for Word, please do as this:

1. Click Enterprise > Split, see screenshot:

doc split word every n pages 5

2. In the popped out Split Document dialog box, click doc split word every n pages 7 button to select a folder to put the split files, and then choose Page from the Split by drop down list, see screenshot:

doc split word every n pages 6

3. After finishing the settings, please click OK, and the whole document will be split into multiple files based on each page, see screenshot:

doc split word every n pages 8

Click to download Kutools for Word and free trial now!


Recommended Productivity Tools

shot kutools word kutools tab 1180x121
shot kutools word kutools plus tab 1180x120
 

Kutools For Word - More Than 100 Advanced Features For Microsoft Word, Save Your 60% Time

  • Complicated and repeated operations can be done a one-time processing in seconds.
  • Insert multiple images across folders into Word document at once.
  • Merge and combine multiple Word files across folders in to one with your desired order.
  • Split the current document into separate documents according to heading 1, section break or other criteria.
  • Convert files between Doc and Docx, Docx and PDF, collection of tools for common conversions and selection, and so on...
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Sergey · 1 months ago
    VBA Script: Split a document into separate files every 10 or n pages not worked
    • To post as a guest, your comment is unpublished.
      skyyang · 24 days ago
      Hello, Sergey,
      The above code works well in my Word document, which Word version do you use?
      And which step went wrong in your operation?
  • To post as a guest, your comment is unpublished.
    Lena · 2 months ago
    i have been trying to split a word file of 166 pages and it gives 166 files each with 166 pages?