跳到主要内容

如何将文档分成多个单词?

如果您有一个庞大的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 Tab支持类似的处理,它允许您在一个Word窗口中浏览多个Word文档,并通过单击它们的选项卡轻松地在它们之间切换。 单击可获得全部功能,免费试用!
使用Firefox在一个窗口中浏览多个Word文档


相关文章:


最佳办公生产力工具

Kutools for Word - 通过 Over 提升您的文字体验 100 显着特点!

🤖 Kutools 人工智能助手:用人工智能改变你的写作 - 生成内容  /  重写文本  /  总结文件  /  查询资料 基于文档,全部在Word中

📘 文档掌握: 分页  /  合并文件  /  以各种格式导出选择(PDF/TXT/DOC/HTML...)  /  批量转换为PDF  /  将页面导出为图像  /  一次打印多个文件...

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

🧹 轻松清洁: 移开 多余的空间  /  分节符  /  所有标题  /  文本框  /  超链接  / 如需更多拆卸工具,请前往我们的 删除组...

创意插入: 插 千位分隔符  /  复选框  /  单选按钮  /  扫码支付  /  条码  /  对角线表  /  公式标题  /  图片说明  /  表标题  /  多张图片  / 发现更多 插入组...

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

星级增强: 快速导航至任何位置  /  自动插入重复文本  /  在文档窗口之间无缝切换  /  11 转换工具...

👉 想尝试这些功能吗? Kutools for Word 提供了 60-day免费试用,没有任何限制! 🚀
 
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