Saving each page in a Word Document

P

pk

Hello, I am using Word XP with Win 2K.

I need to somehow save each separate page of a Word document as new MS Word documents. This procedure must also preserve the headers, footers and margin settings of the source document.

Would it be possible to print each page to a new Word file?

I'm rather a novice at coding in Word, so your example code would be the most helpful thing I could get.

Thanks in advance for your assistance.
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Try the following:

Dim source As Document, sourcename As String
Dim Counter As Long, pages As Long, Docname As String
sourcename = ActiveDocument.FullName
Selection.HomeKey Unit:=wdStory
pages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
ActiveDocument.Range.Delete
ActiveDocument.SaveAs "D:\Documents.Temp.dot", wdDocumentTemplate
Set source = Documents.Open(sourcename)
Counter = 0
While Counter < pages
Counter = Counter + 1
Docname = "Page" & Format(Counter)
source.Bookmarks("\Page").Range.Cut
Documents.Add "D:\Documents.Temp.dot"
Selection.Paste
ActiveDocument.SaveAs FileName:=Docname, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
ActiveDocument.Close
Wend
Source.Close wdDoNotSaveChanges

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top