|
|
How can I separate a large word document by hard pagebreaks into separate files? Here is what I have, ... but doesn't seem to work correctly:
Dim i As Integer
Dim iNumPages As Integer
Dim sCurrentDoc As String
sCurrentDoc = ActiveDocument.Name
'Get the current document's name
iNumPages = 1
'Get the number of docs
For i = 1 To iNumPages
'For as many times as there are docs
Selection.GoTo What:=wdGoToPage, which:=wdGoToAbsolute, Count:=1
Selection.MoveDown Unit:=wdPageBreak, Count:=1, Extend:=wdExtend
Selection.Cut
'Copy the selection
Documents.Add
'Add a new document
Selection.Paste
'Paste
ActiveDocument.SaveAs , FileFormat:=wdFormatDocument
'Save the new document using first line as file name
ActiveDocument.Close
'Close this new document
Documents(sCurrentDoc).Activate
'Activate the document where we started from
Next i
|
|