将文档的每一页拆分为单独的文档?

将文档的每一页拆分为单独的文档?

有没有办法将 85 页的 Word 文档分成 85 个单独的文档?

Adobe Acrobat 可以使用“拆分文档”功能实现这一点。

答案1

Word 中没有内置功能可以执行此操作,但您可以使用宏。

Sub MakeSepDocs()
Dim doc As Word.Document, rng As Word.Range
Dim newDoc As Word.Document, fName As String
Dim sep As String, nbr As Integer, sNbr As String
sep = Application.PathSeparator

Set doc = ActiveDocument
Selection.HomeKey Word.WdUnits.wdStory
fName = Mid(doc.FullName, InStrRev(doc.FullName, sep) + 1, _
    InStrRev(doc.FullName, ".") - InStrRev(doc.FullName, sep) - 1)
On Error Resume Next
Repeat:
Set rng = doc.Bookmarks("\page").Range
rng.Select
Set newDoc = Documents.Add
nbr = nbr + 1
sNbr = Format(nbr, "00")
newDoc.Content.FormattedText = rng.FormattedText
newDoc.SaveAs2 doc.path & sep & fName & sNbr, Word.WdSaveFormat.wdFormatXMLDocument
newDoc.Close
DoEvents
doc.Activate
Selection.Collapse Word.WdCollapseDirection.wdCollapseEnd
If Selection.Range.Start = doc.Bookmarks("\EndOfDoc").Range.Start Then Exit Sub
GoTo Repeat
End Sub

相关内容