Solved

Split document based on page breaks

Posted on 2013-06-12
2
673 Views
Last Modified: 2013-06-12
Dear Experts:

I got a huge word document with lots of page breaks (Strg + Enter) .

Is it possible to split this document based on the page breaks, i.e. ...

If a document has got 4 page breaks, this document gets split based on these page breaks and saved individually, i.e. 5 different documents, named doc1 till doc5 are created and saved.

I hope this is feasible and does not require too much coding work.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
Comment
Question by:AndreasHermle
2 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39241067
Hi

pls refer to http://www.extendoffice.com/documents/word/966-word-split-document-into-multiple-documents.html

Sub SplitIntoPages() 
Dim docMultiple As Document 
Dim docSingle As Document 
Dim rngPage As Range 
Dim iCurrentPage As Integer 
Dim iPageCount As Integer 
Dim strNewFileName As String 
Application.ScreenUpdating = False 'Makes the code run faster and reduces screen _
flicker a bit. 
Set docMultiple = ActiveDocument 'Work on the active document _
(the one currently containing the Selection) 
Set rngPage = docMultiple.Range 'instantiate the range object
iCurrentPage = 1 
'get the document's page count
iPageCount = docMultiple.Content.ComputeStatistics(wdStatisticPages) 
Do Until iCurrentPage > iPageCount 
If iCurrentPage = iPageCount Then 
rngPage.End = ActiveDocument.Range.End 'last page (there won't be a next page) 
Else
'Find the beginning of the next page
'Must use the Selection object. The Range.Goto method will not work on a page
Selection.GoTo wdGoToPage, wdGoToAbsolute, iCurrentPage + 1 
'Set the end of the range to the point between the pages
rngPage.End = Selection.Start 
End If 
rngPage.Copy 'copy the page into the Windows clipboard
Set docSingle = Documents.Add 'create a new document
docSingle.Range.Paste 'paste the clipboard contents to the new document
'remove any manual page break to prevent a second blank
docSingle.Range.Find.Execute Findtext:="^m", ReplaceWith:="" 
'build a new sequentially-numbered file name based on the original multi-paged file name and path
strNewFileName = Replace(docMultiple.FullName, ".doc", "_" & Right$("000" & iCurrentPage, 4) & ".doc") 
docSingle.SaveAs strNewFileName 'save the new single-paged document
iCurrentPage = iCurrentPage + 1 'move to the next page
docSingle.Close 'close the new document
rngPage.Collapse wdCollapseEnd 'go to the next page
Loop 'go to the top of the do loop
Application.ScreenUpdating = True 'restore the screen updating 
'Destroy the objects.
Set docMultiple = Nothing 
Set docSingle = Nothing 
Set rngPage = Nothing 
End Sub 

Open in new window

Regards
0
 

Author Closing Comment

by:AndreasHermle
ID: 39242644
Great help. thank you very much for your professional help.

Regards, Andreas
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now