|
- 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
复制代码 |
评分
-
1
查看全部评分
-
|