2015年5月25日 星期一

將一個word檔一頁一頁分離存檔

將一個word檔一頁一頁分離存檔
1.打開word,按Alt+F11


2.貼上"下列程式碼"按play鍵
;-------------------------------------------------------------

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
;-------------------------------------------------------------

3.產生分頁檔於C槽


沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。