|
有一个word 300多页 ,想把这个文档单位保存为300多个word, 按页保存, 里面格式不变,在百度搜了一下 有个网页是这些说的,但我个人不会宏,能帮忙做一个吗。
不到遇到问题,总是不会去寻找解决问题的办法,今天又发现word的一个功能:按分页另存为多个文件:工具——宏——这个必须用VBA来实现了,在此文档的ThisDocument的代码页中输入以下代码,然后执行Sub SaveParagraph() 即可
Sub BreakOnPage()
' Used to set criteria for moving through the document by page.
Application.Browser.Target = wdBrowsePage
For i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of Pages")
'Select and copy the text to the clipboard
ActiveDocument.Bookmarks("\page").Range.Copy
' Open new document to paste the content of the clipboard into.
Documents.Add
Selection.Paste
' Removes the break that is copied at the end of the page, if any.
Selection.TypeBackspace
ChangeFileOpenDirectory "C:"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
ActiveDocument.Close
' Move the selection to the next page in the document
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
|
|