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 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.
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!
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:
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:
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:
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:
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:
2. In the popped out Split Document dialog box, click button to select a folder to put the split files, and then choose Page from the Split by drop down list, see screenshot:
3. After finishing the settings, please click OK, and the whole document will be split into multiple files based on each page, see screenshot:
Recommended Productivity Tools
- 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...