python分解word文档为多个_如何将一个word文档按页分割成多个word文档-百度经验...

粘贴下面的代码:

Option Explicit

Sub SplitPagesAsDocuments()

Dim oSrcDoc As Document, oNewDoc As Document

Dim strSrcName As String, strNewName As String

Dim oRange As Range

Dim nIndex As Integer

Dim fso As Object

Set fso = CreateObject(“Scripting.FileSystemObject”)

Set oSrcDoc = ActiveDocument

Set oRange = oSrcDoc.Content

oRange.Collapse wdCollapseStart

oRange.Select

For nIndex = 1 To ActiveDocument.Content.Information(wdNumberOfPagesInDocument)

oSrcDoc.Bookmarks(“\page”).Range.Copy

oSrcDoc.Windows(1).Activate

Application.Browser.Target = wdBrowsePage

Application.Browser.Next

strSrcName = oSrcDoc.FullName

strNewName = fso.BuildPath(fso.GetParentFolderName(strSrcName), _

fso.GetBaseName(strSrcName) & “_” & nIndex & “.” & fso.GetExtensionName(strSrcName))

Set oNewDoc = Documents.Add

Selection.Paste

oNewDoc.SaveAs strNewName

oNewDoc.Close False

Next

Set oNewDoc = Nothing

Set oRange = Nothing

Set oSrcDoc = Nothing

Set fso = Nothing

MsgBox “结束!”

End Sub

    原文作者:龚禧学长
    原文地址: https://blog.csdn.net/weixin_34617955/article/details/113971061
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞