跳至主要内容

Kutools for Office — 一套工具,五种功能。事半功倍。

如何将Word文档每5页或n页拆分为单独的文件?

Author: Xiaoyang Last Modified: 2025-08-22

在处理大型Word文档时,您可能需要将文档拆分为较小的独立文件,以便于处理、共享或编辑。每隔5页、10页或指定数量的页面拆分文档可以是更高效管理冗长内容的实用解决方案。

手动逐页复制和粘贴既耗时又低效。在本教程中,我们将介绍快速简便的方法,将Word文档每N页拆分为单独的文件:

使用VBA代码将Word文档每N页拆分为单独的文件

使用一项强大功能将Word文档每N页拆分为单独的文件


使用VBA代码将Word文档每N页拆分为单独的文件

要将大型文档基于每N页拆分为单独的文件,以下VBA代码可以帮助您。请按照以下步骤操作:

  1. 按住ALT + F11打开Microsoft Visual Basic for Applications窗口。
  2. 点击插入 > 模块,并将以下代码复制粘贴到空白模块中:
  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. 粘贴代码后,仍然在 Microsoft Visual Basic for Applications 窗口中,点击 工具 > 引用。在 引用 - 项目 对话框中,勾选 Microsoft VBScript 正则表达式 5.5 选项,该选项位于 可用引用 列表中。参见截图:
    VBA window with Tools > References selected Arrow Microsoft VBScript Regular Expressions 5.5 checked in the References-Project dialog box
  5. 点击确定,然后按F5运行代码。
  6. 将出现一个浏览文件夹对话框。选择要保存拆分文件的文件夹,然后点击确定
  7. Browse For Folder dialog box

  8. 另一个提示框将出现,要求输入您希望拆分的页数。输入所需的页数并点击确定
  9. Dialog box for entering the page number to split based on

  10. 文档将被每N页拆分为单独的文件。导航到指定的文件夹查看结果。
  11. The document is split into separate files every N pages


使用一项强大功能将Word文档每N页拆分为单独的文件

Kutools for Word提供了一个强大的文档拆分功能,使您可以根据标题1、分页符、分节符或页面快速将大型Word文档拆分为多个独立文件。此功能简化了原本繁琐的手动过程。

Kutools for Word搭载 AI 🤖,提供超过 100 项实用功能,简化您的任务。
  1. 点击 Kutools Plus > 文档拆分.

    Split button on the Kutools tab on the ribbon

  2. 在弹出的对话框中,根据需要配置以下选项:
    1. 类型菜单中选择文档页码倍数选项。
    2. 在输入框中指定n值。
    3. 选择保存位置。
    4. 为拆分的文档指定前缀。

      Split Document dialog box

  3. 完成设置后,点击 确定。文档将根据所选选项(例如,每7页)拆分为多个文件。

    The document is split into separate files every N pages

使用Kutools for Word中的文档拆分功能,可以轻松高效地将大型文档拆分为较小且易于管理的文件。

Kutools for Word 是终极的 Word 插件,能够简化您的工作并提升文档处理技能。立即获取!

最佳Office办公效率工具

Kutools for Word - 用超过100项强大功能全面提升你的Word体验!

🤖 Kutools AI 功能AI助手 / 实时助手 / 超级润色(保留格式)/ 超级翻译(保留格式)/ AI遮挡 / AI校正……

📘 文档掌控分割页面 / 文档合并 / 区域导出为多种格式(PDF/TXT/DOC/HTML等)/ 批量转换为PDF……

正文编辑跨多个文件批量查找与替换 / 一键调整所有图片大小 / 翻转表格行列 / 表格转文本……

🧹 高效清理:一扫多余空格 / 分节符 / 文本框 / 超链接 / 想了解更多删除工具,请前往删除分组……

创意插入:插入千位区分符 /复选框 /选项按钮 / 二维码 / 条形码 / 批量插入图片 / 更多内容请见插入分组……

🔍 精准选取:快速定位指定页面 / 表格 / 形状 / 标题段落 / 利用更多 选择 功能提升导航体验……

实用增强跳转任意区域 / 自动插入重复文本 / 文档窗口间一键切换 /11 转换工具……

🌍 支持40多种语言:自由选择你喜欢的界面语言——Kutools支持英语、西班牙语、德语、法语、中文及其他40余种语言!

Kutools and Kutools Plus tabs on the Word Ribbon
👉 想立即体验这些功能?马上下载 Kutools for Word!🚀
 

✨ Kutools for Office – 一次安装,五大强力工具集成!

内含 Office Tab Pro · Kutools for Excel · Kutools for Outlook · Kutools for Word · Kutools for PowerPoint

📦 五大工具一站式集成 | 🔗 无缝兼容Microsoft Office | ⚡立即提升效率、节省时间

最佳Office办公效率工具

Kutools for Word - 100+ 项Word工具