Skip to main content

如何將 Word 文件分割成多個文件?

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

如果您有一個大型的 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內建人工智慧 ?,提供超過 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. 點擊確定。

文件將根據指定的方法進行拆分,並且新文件將保存到指定的文件夾中。

注意:

  • 如果按每 n 頁拆分,請在相關框中指定數字。

    Split by Every n pages

  • 對於自定義頁面範圍,請輸入逗號分隔的頁碼(例如,1,3-5,12)。

    Custom Page Ranges

Kutools for Word 是終極的 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 工具