怎么快速拆分word文档为多个文档
-
使用Word的拆分功能:打开Word文档,点击“文件”菜单,选择“另存为”选项,选择“单个文件网页(.htm,.html)”格式,保存后会生成一个包含多个网页的文件夹,每个网页对应原来Word文档的一页。可以将这些网页重新命名为Word文档格式的文件。
-
使用VBA宏:打开Word文档,按下“Alt+F11”键进入VBA编辑器,选择“插入”菜单,选择“模块”选项,新建一个VBA宏,在代码区输入以下代码:
Sub SplitDocument()
Dim i As Long Dim j As Long Dim k As Long Dim l As Long Dim s As String Dim doc As Document Dim newdoc As Document
Set doc = ActiveDocument j = doc.Paragraphs.Count
For i = 1 To j If doc.Paragraphs(i).Range.Information(wdActiveEndAdjustedPageNumber) <> l Then l = doc.Paragraphs(i).Range.Information(wdActiveEndAdjustedPageNumber) Set newdoc = Documents.Add k = k + 1 s = "Section_" & k & ".docx" newdoc.SaveAs2 s doc.Paragraphs(i).Range.Copy newdoc.Range.Paste Else doc.Paragraphs(i).Range.Copy newdoc.Range.Paste End If Next i
newdoc.Close wdSaveChanges Set newdoc = Nothing Set doc = Nothing
End Sub
保存后按下“F5”键运行该宏即可将Word文档拆分为多个文档,每个文档包含一页。
原文地址: https://www.cveoy.top/t/topic/84W 著作权归作者所有。请勿转载和采集!