跳到主要內容

如何將文檔分成多個單詞?

如果您有大量的Word文檔,需要將其拆分為多個文檔,請花幾分鐘閱讀本教程。 本教程將向您展示兩種將文檔拆分為多個文檔的方法。


使用VBA通過指定的分隔符拆分Word文檔

此方法將引入VBA來通過Word中指定的分隔符將Word文檔拆分,而不是手動將文檔拆分為多個文檔。 請執行以下操作:

1。 按 Alt + F11鍵 鍵一起打開Microsoft Visual Basic for Application窗口;

2。 點擊 插入 > 模塊,然後將以下VBA代碼粘貼到新打開的“模塊”窗口中。

VBA:通過分隔符將Word文檔拆分為多個文檔

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文檔中,請單擊“是”按鈕繼續。

注意:
(1)確保將分隔符添加為與 “ ///” 在子測試中,您要分隔的每個文本部分之間的文檔。 此外,您可以更改 “ ///” 任何分隔符,以滿足您的需要。
(2)您可以更改文件 “筆記” 在子測試中以滿足您的需求。
(3)分割文件將與原始文件保存在同一位置。
(4)不需要在原始文件的末尾添加定界符,如果這樣做,則分割後將出現空白文檔。

使用VBA按頁面拆分Word文檔

這是另一個VBA,可幫助您在Word中快速將一個Word文檔按頁面拆分成多個。 請執行以下操作:

1。 按 Alt + F11鍵 鍵一起打開Microsoft Visual Basic for Application窗口;

2。 點擊 插入 > 模塊,然後將以下VBA代碼粘貼到新打開的“模塊”窗口中。

VBA:在Word中按頁面將文檔拆分為多個文檔

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 _
(the one currently containing the Selection)
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 (there won't be a 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通過標題/頁面/分節符/分頁符拆分Word文檔

如果您安裝了Kutools for Word,則可以應用它 分裂 功能可輕鬆在Word中按頁面,標題,分節符或分頁符將一個文檔拆分為多個文檔。

Kutools for Word 是一款終極 Word 插件,可簡化您的工作並提高您的文件處理技能。 免費試用 60 天! 現在得到它!

1。點擊 Kutools 加 > 分裂 使之成為可能 分裂 功能。

2。 在屏幕上打開的“拆分”對話框中,您可以執行以下操作:

(1)從 分割為 下拉列表。
此功能支持6種拆分方式:標題1,分頁符,分節符,頁面,每n頁和自定義頁面範圍,如下面的屏幕截圖所示:

(2)點擊 瀏覽 按鍵  指定 將拆分文檔保存到的目標文件夾;

(3)在關鍵字欄中輸入關鍵字作為新文檔名稱的前綴。 文件前綴 框。

提示:
(1)如果指定拆分當前文檔 每n頁,您需要在 每n頁 框;

(2)如果您指定按自定義頁面範圍分割當前文檔,則需要在這些自定義頁面範圍中輸入用逗號分隔的自定義頁面範圍。 框,例如,在框中鍵入1、3-5、12。

3。 點擊 Ok 按鈕開始拆分。

然後,以指定的拆分方式拆分當前文檔,新文檔將批量保存到目標文件夾中。

分頁瀏覽和編輯多個Word文檔,例如Firefox,Chrome,Internet Explore 10!

您可能很熟悉在Firefox / Chrome / IE中查看多個網頁,並通過輕鬆單擊相應的選項卡在它們之間進行切換。 在這裡,Office選項卡支持類似的處理,使您可以在一個Word窗口中瀏覽多個Word文檔,並通過單擊其選項卡輕鬆在它們之間切換。 單擊可獲得全部功能,免費試用!
使用Firefox在一個窗口中瀏覽多個Word文檔


相關文章:


最佳辦公生產力工具

Kutools for Word - 透過 Over 提升您的文字體驗 100 顯著特點!

🤖 Kutools 人工智慧助手:用人工智慧改變你的寫作 - 生成內容  /  重寫文字  /  總結文件  /  查詢資料 基於文檔,全部在Word中

📘 文件掌握: 分頁  /  合併文件  /  以各種格式匯出選擇(PDF/TXT/DOC/HTML...)  /  批次轉換為PDF  /  將頁面匯出為圖像  /  一次列印多個文件...

內容編輯: 批量查找和替換 跨多個文件  /  調整所有圖片的大小  /  轉置表行和列  /  將表格轉換為文字...

🧹 輕鬆清潔: 移開 多餘的空間  /  分節符  /  所有標題  /  文本框  /  超鏈接  / 如需更多拆卸工具,請前往我們的 刪除組...

創意插入: 插入 千位分隔符  /  複選框  /  單選按鈕  /  QR Code  /  條碼  /  對角線表  /  公式標題  /  圖片說明  /  表格標題  /  多張圖片  / 發現更多 插入組...

🔍 精準選擇:精確定位 特定頁面  /    /  形狀  /  標題段落  / 增強導航功能 更多 選擇功能...

星級增強: 快速導航至任何位置  /  自動插入重複文字  /  在文檔視窗之間無縫切換  /  11 轉換工具...

???? 想嘗試這些功能嗎? Kutools for Word 提供了 60天免費試用,沒有任何限制! 🚀
 
Comments (45)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
VBA: Split Document into Multiple Documents by Page in Word - in this when we run it, outcome comes in portrait layout only. If original doc is in landscape then full data of the original doc does not come in the pages breaked by this vba.. There must be seperate vba for portrait and landscape docs.
This comment was minimized by the moderator on the site
I use the "split"-function of "Kutools For Word 9.00" with "header 1" and it works for 48 documents and then it simply stops without any message, as if it wohl have been finished. But I have 700 "header 1" in a 2000 pages document!
Is it simply too much for the tool or is there any other reason?
This comment was minimized by the moderator on the site
your code add new blank page in every page
This comment was minimized by the moderator on the site
This worked fine up until yesterday with Office365, but now I constantly get a runtime error '4605' stating this command is not available. Sometimes at the first page, sometimes at the 3rd page...I can't make it past 3 pages anymore. It happens with line 28 above...

docSingle.Range.Paste 'paste the clipboard contents to the new document
This comment was minimized by the moderator on the site
I've got this error too - Did you get anywhere with it?


Thanks
This comment was minimized by the moderator on the site
yes...i have to run it on the local hard drive. if i run it on a network file or with RemotePC it. has something to do with the script having to wait too long in between commands and it errors out copy and pasting to the clipboard. hope that helps!!
This comment was minimized by the moderator on the site
I copied the document distribution macro 'Split Word Document By Specified Delimiter With VBA', but in the line of 'sub test', the software reads it as a new macro and there are two macros here.
This comment was minimized by the moderator on the site
The script saves a two pages document, the second is total blank.

How to solve this?
This comment was minimized by the moderator on the site
Hi Jorge,
The VBA script introduced splits document by the separator “///”, and you do not need to add delimiter to the end of the original file, if you do, there will be a blank document after splitting.
This comment was minimized by the moderator on the site
Hi kellytte, Could you please explain a little further? I copy and paste the VBA script under the "Split Word by Document with VBA" from above and after I run the process following the instructions above, I always have to manually delete a 2nd blank page on each of the new documents that were created. Are you saying there is something that needs to be removed from the VBA script that will cause this to stop?
This comment was minimized by the moderator on the site
The split works great for me but on page in the merge file turns into 1.5 pages - something with the page layout (+ additional empty page at the end). any ideas how to go around that?
This comment was minimized by the moderator on the site
The Split Word By Document with VBA worked for me, but it is adding a blank page at the end of each document. Is there a way around this?
This comment was minimized by the moderator on the site
I am working on this as well but have not found a way to do it besides manually.
This comment was minimized by the moderator on the site
Does not work at all for me. Goes through the motions but no documents are saved. Maybe because I am using .DOCX files?
This comment was minimized by the moderator on the site
After playing with this code for over an hour I discovered you have to save the document you mail merged then you can run the code on the saved document that has all the pages you need to split up. Hope this helps.
This comment was minimized by the moderator on the site
I always start with a newly-saved document. I found the split documents were actually saved somewhere (I forget; doesn't matter) they were text only - all the formatting had been dropped.
This comment was minimized by the moderator on the site
Maybe something to do with Windows 7 settings? Thoughts from anyone?
This comment was minimized by the moderator on the site
Mais comment garder une mise en page complexe (image de fond, marges, etc) ?
Great but how to keep the lay-out (background image, margins ?)
This comment was minimized by the moderator on the site
Can you split the document based on Heading 1 styles as your "delimiter".
This comment was minimized by the moderator on the site
Hi Andrew,
The VBA script can split the entire document by page. If you need to split by heading 1, we suggest to try Kutools for Word’s Split (Document) feature.
This comment was minimized by the moderator on the site
Downloaded fodler doesnt open at all. Waiting for a long time.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations