Hi,
This may be of some help:
Is is possible to save each page in a word document as a new document? For example I have a document called testdoc with 250 pages. What I want to do is automatically save each individual page as a new document. So page 1 would be testdoc1.doc and page 2 would be testdoc2.doc and so on. I am not that picky about how it is named.
Thanks
Dodge20
fumei (TechnicalUser) Jun 3, 2004
Yes. The following creates individual files for each page of a document. It add "Pagepagenumberof" to the original filename, and saves them into the same folder holding the original file. So page 4 of "test.doc" will be saved as "Page4oftest.doc"
NOTE: this creates a document for every page, including blank ones. It could be tweaked to determine blank pages.
CODE
Sub EachPageDoc()
Dim aDoc As Document
Dim lngPageCount As Long, lngCurrentPage As Long
Dim var As Variant
Set aDoc = ActiveDocument
lngCurrentPage = 1
' use constant for number of pages
lngPageCount = aDoc.BuiltInDocumentProperties(14)
' turn off screen updating otherwise
' your brain will turn into mush
Application.ScreenUpdating = False
' go to top of doc
Selection.HomeKey Unit:=wdStory
For var = 1 To lngPageCount
' make selection of page, and copy it
aDoc.Bookmarks("\page").Select
Selection.Copy
' make new document, paste, and save
Application.Documents.Add
Selection.PasteSpecial
ActiveDocument.SaveAs FileName:=aDoc.Path & _
Application.PathSeparator & "Page" & lngCurrentPage & "of" & aDoc.Name
ActiveDocument.Close
' go to next page
aDoc.Activate
Selection.GoTo what:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
lngCurrentPage = lngCurrentPage + 1
Next
' turn screen update back on
Application.ScreenUpdating = True
' release aDoc
Set aDoc = Nothing
MsgBox "Done."
End Sub
Hope this helps.
Gerry
dodge20 (MIS) Jun 3, 2004
This is real close, for every page it puts a blank page after it. Can this be eliminated? Also is it possible to save it as a .txt file?
Here is a star for your efforts so far.
Dodge20
dodge20 (MIS) Jun 3, 2004
2 things to add to my last post. It looks like it just has 1 blank line after each page which causes the new blank page. Also if I can get it to save a .txt then it will eliminate the extra pages altogether.
Dodge20
Good Luck!
Peter Moran