A
AnnP
I used code in a macro from the following article to
separate merged pages into separate files. I would like
to be able to name each file from a data source, e.g.,
from an excel speadsheet or text from each page that is
being separated. Can someone help me modify the code
below to do that?
D2000: How to Programmatically Save Each Page or Section
of a Document As Separate File.
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
separate merged pages into separate files. I would like
to be able to name each file from a data source, e.g.,
from an excel speadsheet or text from each page that is
being separated. Can someone help me modify the code
below to do that?
D2000: How to Programmatically Save Each Page or Section
of a Document As Separate File.
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