P
pontellt
I need to split a word document into several seperate documents.
The main document is 1076 pages, but every 2 pages is a "new" document
that I want to split out and save.
I found this code on this group:
Sub ExtractPage()
Dim i As Integer
Dim iNumPages As Integer
Dim sCurrentDoc As String
sCurrentDoc = Activedocument.name
'Get the current document's name
iNumPages = Activedocument.ComputeStatistics(wdStatisticPages)
'Get the number of pages
For i = 1 To iNumPages
'For as many times as there are pages
Selection.GoTo What:=wdGoToPage, which:=wdGoToAbsolute, Count:=i
'Goto pagenumber i
Selection.GoTo What:=wdGoToBookmark, name:="\Page"
'Select this page
Selection.Copy
'Copy the selection
Documents.Add
'Add a new document
Selection.Paste
'Paste
Activedocument.SaveAs FileName:="newdocument" & i
'Save the new document as "newdocument" and the value of the
counter i
Activedocument.Close
'Close this new document
Documents(sCurrentDoc).Activate
'Activate the document where we started from
Next i
End Sub
Problem is, I am new at this and can't figure out how I tell this that
each new document is only 2 pages..
Thanks!
The main document is 1076 pages, but every 2 pages is a "new" document
that I want to split out and save.
I found this code on this group:
Sub ExtractPage()
Dim i As Integer
Dim iNumPages As Integer
Dim sCurrentDoc As String
sCurrentDoc = Activedocument.name
'Get the current document's name
iNumPages = Activedocument.ComputeStatistics(wdStatisticPages)
'Get the number of pages
For i = 1 To iNumPages
'For as many times as there are pages
Selection.GoTo What:=wdGoToPage, which:=wdGoToAbsolute, Count:=i
'Goto pagenumber i
Selection.GoTo What:=wdGoToBookmark, name:="\Page"
'Select this page
Selection.Copy
'Copy the selection
Documents.Add
'Add a new document
Selection.Paste
'Paste
Activedocument.SaveAs FileName:="newdocument" & i
'Save the new document as "newdocument" and the value of the
counter i
Activedocument.Close
'Close this new document
Documents(sCurrentDoc).Activate
'Activate the document where we started from
Next i
End Sub
Problem is, I am new at this and can't figure out how I tell this that
each new document is only 2 pages..
Thanks!