當前位置:編程學習大全網 - 網站源碼 - 將word文檔分頁 成為N個文檔

將word文檔分頁 成為N個文檔

200除以12大概的等於17,分別在第17,34,51,68,85,102,119,136,153,170,187頁等插入分節符下壹頁。

打開文檔,打開VB編輯器,將下面的代碼粘貼到編輯器中,F5運行:

Sub BreakOnSection()

' Used to set criteria for moving through the document by section.

Application.Browser.Target = wdBrowseSection

'A mailmerge documents ends with a section break next page.

'Subtracting one from the section count stop error message.

For i = 1 To ((ActiveDocument.Sections.Count) - 1)

'Select and copy the section text to the clipboard

ActiveDocument.Bookmarks("\Section").Range.Copy

'Create a new document to paste text from clipboard.

Documents.Add

Selection.Paste

' Removes the break that is copied at the end of the section, if any.

Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend

Selection.Delete Unit:=wdCharacter, Count:=1ChangeFileOpenDirectory "C:\"

DocNum = DocNum + 1

ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"

ActiveDocument.Close

' Move the selection to the next section in the document

Application.Browser.Next

Next i

ActiveDocument.Close

savechanges:=wdDoNotSaveChanges

End Sub

  • 上一篇:fcpx10.4.10 gpu使用率低
  • 下一篇:編譯安卓5.0源碼使用什麽系統
  • copyright 2024編程學習大全網