跳至主要内容

如何将Word文档拆分为多个文档?

Author: Amanda Li Last Modified: 2025-05-07

如果您有一个需要拆分为多个较小文档的大型Word文档,本教程将向您介绍三种有效的方法。无论您喜欢使用VBA按特定分隔符或页面进行拆分,还是选择Kutools for Word的简化功能,您都会找到适合您需求的解决方案。


使用VBA按指定分隔符拆分Word文档

与其手动拆分文档,您可以使用VBA按特定分隔符拆分Word文档。请按照以下步骤操作:

  1. Alt + F11 打开 Microsoft Visual Basic for Applications 窗口。
  2. 点击 插入 > 模块,然后将以下VBA代码粘贴到模块窗口中。
    Sub SplitNotes(delim As String, strFilename As String)
    Dim doc As Document
    Dim arrNotes
    Dim I As Long
    Dim X As Long
    Dim Response As Integer
    arrNotes = Split(ActiveDocument.Range, delim)
    Response = MsgBox("This will split the document into " & UBound(arrNotes) + 1 & " sections. Do you wish to proceed?", 4)
    If Response = 7 Then Exit Sub
    For I = LBound(arrNotes) To UBound(arrNotes)
    If Trim(arrNotes(I)) <> "" Then
    X = X + 1
    Set doc = Documents.Add
    doc.Range = arrNotes(I)
    doc.SaveAs ThisDocument.Path & "\" & strFilename & Format(X, "000")
    doc.Close True
    End If
    Next I
    End Sub
    Sub test()
    'delimiter & filename
    SplitNotes "///", "Notes "
    End Sub
  3. 点击“运行”按钮或按 F5 执行VBA代码。
  4. 在弹出的Microsoft Word对话框中,点击 .

    Confirmation dialog

注意:

  • 脚本将在文档中查找“///”(代码第22行)以确定应将文本拆分为单独文件的位置。如果您的文档中的分隔符与“///”不同,则必须更新VBA代码以反映正确的分隔符,或者修改您的文档,在需要拆分的位置添加“///”。
  • 您可以将代码第22行的“Notes”替换为任何文本,以为拆分后的文档创建更有意义的文件名前缀。
  • 拆分后的文档将保存在与原始文件相同的位置。
  • 文档末尾不需要分隔符;否则会创建一个空白文件。

使用Kutools for Word按标题/页面/分节符/分页符拆分Word文档

与手动方法或VBA相比,Kutools for Word提供了更便捷、更灵活的方式来拆分文档。它提供了多种选项,可以按标题、页面、分节符、分页符、每n页或自定义页面范围来拆分文档,使您可以根据具体需求定制拆分过程。

Kutools for Word内置 AI 🤖,提供超过 100 种实用功能,助您简化任务。
  1. 点击 Kutools Plus > 文档拆分 以启用 文档拆分 功能。

    Split option on the Kutools Plus tab on the ribbon

  2. 在“文档拆分”对话框中,配置以下选项:
    Kutools Split Document dialog box
    1. 类型 下拉列表中选择一种拆分方法。可用选项包括标题 1、分页符、分节符、页面、每n页或自定义页面范围。

      Split by options

    2. 点击 浏览 按钮 Path selection button 选择用于保存拆分后文档的目标文件夹。
    3. 文档前缀 字段中输入关键字作为新文档名称的前缀。 提示: 点击 刷新 按钮 Refresh button 可以在 预览 框中预览拆分后的文档名称。
    4. 点击 确定

文档将根据指定的方法进行拆分,并且新文件将保存到指定的文件夹中。

注意:

  • 如果按 文档页码倍数拆分,请在相关框中指定数字。

    Split by Every n pages

  • 对于自定义页面范围,请用逗号分隔输入(例如, 1,3-5,12).

    Custom Page Ranges

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

多文档标签式浏览与编辑,就像在 Chrome 和 Edge 中一样!

就像在 Chrome、Safari 和 Edge 中浏览多个网页一样,Office Tab 让您可以在一个窗口中打开和管理多个 Word 文档。现在只需点击标签即可轻松切换文档!立即免费试用 Office Tab!

Browse multiple word documents in one window just like in Chrome


使用VBA按页面拆分Word文档

如果您需要快速将Word文档拆分为多个文档,每个文档包含一页,您可以使用VBA宏自动完成此任务。请按照以下步骤操作:

  1. Alt + F11 打开 Microsoft Visual Basic for Applications 窗口。
  2. 点击 插入 > 模块,然后将以下VBA代码粘贴到新的模块窗口中:
    Sub SplitIntoPages()
    Dim docMultiple As Document
    Dim docSingle As Document
    Dim rngPage As Range
    Dim iCurrentPage As Integer
    Dim iPageCount As Integer
    Dim strNewFileName As String
    Application.ScreenUpdating = False 'Makes the code run faster and reduces screen flicker a bit.
    Set docMultiple = ActiveDocument 'Work on the active document
    Set rngPage = docMultiple.Range 'Instantiate the range object
    iCurrentPage = 1
    'Get the document's page count
    iPageCount = docMultiple.Content.ComputeStatistics(wdStatisticPages)
    Do Until iCurrentPage > iPageCount
        If iCurrentPage = iPageCount Then
            rngPage.End = ActiveDocument.Range.End 'Last page (no next page)
        Else
            'Find the beginning of the next page
            'Must use the Selection object. The Range.Goto method will not work on a page
            Selection.GoTo wdGoToPage, wdGoToAbsolute, iCurrentPage + 1
            'Set the end of the range to the point between the pages
            rngPage.End = Selection.Start
        End If
        rngPage.Copy 'Copy the page into the Windows clipboard
        Set docSingle = Documents.Add 'Create a new document
        docSingle.Range.Paste 'Paste the clipboard contents to the new document
        'Remove any manual page break to prevent a second blank
        docSingle.Range.Find.Execute Findtext:="^m", ReplaceWith:=""
        'Build a new sequentially numbered file name based on the original multi-paged file name and path
        strNewFileName = Replace(docMultiple.FullName, ".doc", "_" & Right$("000" & iCurrentPage, 4) & ".doc")
        docSingle.SaveAs strNewFileName 'Save the new single-paged document
        iCurrentPage = iCurrentPage + 1 'Move to the next page
        docSingle.Close 'Close the new document
        rngPage.Collapse wdCollapseEnd 'Go to the next page
    Loop 'Go to the top of the do loop
    Application.ScreenUpdating = True 'Restore the screen updating
    'Destroy the objects.
    Set docMultiple = Nothing
    Set docSingle = Nothing
    Set rngPage = Nothing
    End Sub
  3. 点击“运行”按钮或按 F5 执行VBA代码。

注意:拆分后的文档将保存在与原始文件相同的位置。


相关文章:


最佳办公生产力工具

Kutools for Word - 通过超过 100 个卓越功能提升您的 Word 体验!

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

📘 文档精通拆分页面 / 合并文档 / 以多种格式导出选择内容(PDF/TXT/DOC/HTML...)/ 批量转换为 PDF...

内容编辑跨多个文件批量查找和替换 / 调整所有图片大小 / 翻转表格的行和列 / 表格转文本...

🧹 轻松清理:清除多余空格 / 分节符 / 文本框 / 超链接 / 更多清理工具,请前往“清除”组...

创意插入:插入千位分隔符 / 复选框 / 单选按钮 / 二维码 / 条形码 / 多张图片 / 在“插入 ”组中发现更多...

🔍 精确选择:定位特定页面 / 表格 / 形状 / 标题段落 / 使用更多 选择 功能增强导航...

星级增强功能跳转到任意位置 / 自动插入重复文本 / 在文档窗口之间切换 / 11 转换 工具...

Kutools and Kutools Plus tabs on the Word Ribbon
👉 想尝试这些功能吗?立即下载 Kutools for Word!🚀
 

最佳办公生产力工具

Kutools for Word - 100+ Word 工具