Solved

Split every page of a word document into a new file

Posted on 2008-10-10
8
2,295 Views
Last Modified: 2013-11-26
in word 2007 I have 850 pages in a document and i want to convert each page of this document into a new file(document).
In the sense I need to make 850 new documents(files) from a file containing 850 pages.
Each page of the document should be created into a new document
Is this possible?
any help would be very appreciated.
0
Comment
Question by:marchaberman
8 Comments
 
LVL 15

Accepted Solution

by:
tenaj-207 earned 125 total points
ID: 22692888
The best way I can think to do this would be to convert the document into a pdf then use Adobe Pro to split up the document easily.  In Adobe 8.1 you do this by;

1) Click on Document then Extract Pages
2) Set it to start at page 1 and finish at page 850
3) Check the box for Extract pages as separate files
4) Click ok and let it run all day

Then if you really need to have it back in word convert it back to text (hopefully you don't have any pictures).
0
 
LVL 16

Assisted Solution

by:sh0e
sh0e earned 125 total points
ID: 22693025
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Word/Q_23615543.html

Click View Tab, Click Macros and View Macros
Type SplitWordDoc and Click Create
Delete Everything and Copy Paste Below Code
File and Save Normal
Go Back to Word, Click Macros and View Macros, Click Run

It should automatically save every page to a separate file with a number appended to the end of the file name.
Public Sub SplitWordDoc()

 

Dim sPath As String

Dim sName As String

Dim p As Long

Dim docNew As Document

Dim rngSource As Range

 

'gets document application path to provide saving location

sPath = ActiveDocument.Path & "\"

sName = Replace(ActiveDocument.Name, ".doc", "", Compare:=vbTextCompare)

 

'go to start of document

Selection.HomeKey wdStory

 

Application.ScreenUpdating = False

 

'get current page count

ActiveDocument.Repaginate

 

'for each page in the document

For p = 1 To ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)

 

    'select the page

    ActiveDocument.Bookmarks("\Page").Range.Select

    'move left 1 character

    Selection.MoveLeft wdCharacter, 1, wdExtend

    'set the range to be copied to new document

    Set rngSource = Selection.Range.FormattedText

 

    'create new document

    Set docNew = Documents.Add

    'copy page contents

    docNew.Range.FormattedText = rngSource

    'save the document

    docNew.SaveAs sPath & sName & "_Page" & p & ".doc"

    'close the document

    docNew.Close True

 

    'go to the next page

    Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext

 

Next p

 

'go to start of document

Selection.HomeKey wdStory

 

Application.ScreenUpdating = True

 

End Sub

Open in new window

0
 

Expert Comment

by:IndyJns
ID: 23435371
Hello, this code saved me HOURS of time!!  Is there a way to modify this code to have every TWO pages saved as a document instead of every page?  Thank You!!!!!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 15

Expert Comment

by:tenaj-207
ID: 23435675
Change the line

'for each page in the document
For p = 1 To ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)

to

'for each page in the document
For p = 2 To ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
0
 

Expert Comment

by:IndyJns
ID: 23440804
Thanks for the quick feedback.  This change did not fix the issue.  It still saves one page only.  The only difference was it started with Page 2.  Any other thoughts?
0
 

Expert Comment

by:IndyJns
ID: 23441493
I sorta got it to work...  :)  

For p = 1 To ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)

   rngSource.EndOf Unit:=wdSection, Extend:=wdExtend
 
  I changed the rngSource to pull the text through the end of the section.  This worked by placing all of the info on one page then saving that page.   However, it also "duplicated" the second page and saved it as its own document as well.  So, this worked for me as I only utilized the odd number documents that were saved and I ignored the even numbered documents.  I'm sure there is a much more elegant way to do this as I am a complete nOOb but the end result got me what I needed...
   
 
0
 

Expert Comment

by:ecajigas
ID: 24803498
Thanks!

I don't know if I have to open a new thread for this pleas you let me know.

I need to do this but to save each page in text (.TXT) format. I found this parameter:

FileFormat  - Optional Variant  - The format in which the document is saved. Can be any WdSaveFormat constant. To save a document in another format, specify the appropriate value for the SaveFormat property of the FileConverter object.

How do I integrate the FileFormat into the script?

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Numbering Only Even Pages - Consecutively -  in Word 2013 3 37
Remove Office macro by VC++ 10 88
Which version of Microsoft Project does my client need? 3 70
Convert .PDF 6 59
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
If you are using Scrum Framework or another agile process, a retrospective may be part of it. Does your team perform retrospectives? Are you getting value from your retrospectives? I see a common anti-pattern when people conduct a retrospective f…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
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.

932 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

12 Experts available now in Live!

Get 1:1 Help Now