Macro to slit word document into separate batches.

Hi,

We have a word document that I want to split into batches of 3 pages.

For example if we get in a 147 document we want to split it every 3 pages. So the end result we will have 49 documents which have 3 pages.

The split is always 3 pages and the amount of pages can change all the time.

I need something like a macro that will do this.

Thanks

Luke
luketrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PandaPantsCommented:
Is there a hard page, a section break, or a reliable string of text that marks the beginning or end of each set of three pages? If we're relying on a "soft" page break that occurs naturally, then the pages will break differently depending on the printer, font size, margins, etc., and Word has a hard time predicting the breaks accurately.
0
GrahamSkanRetiredCommented:
Is this a VBScript question, or is VBA acceptable?
0
luketrAuthor Commented:
It's a VBScript question.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

GrahamSkanRetiredCommented:
And to PandaPant's question? Are the pages defined well enough to be sure that the page splits come where you need them, or is some leeway acceptable?

It may help to post a sample.
0
luketrAuthor Commented:
I have attached an example of the file, this has only 9 pages but the original file has 147.

Thanks

Luke
0
luketrAuthor Commented:
0
luketrAuthor Commented:
I've had to change the file extension to .doc as I’m unable to upload an rtf on this web site.

Thanks

Luke
0
Stacy BrownSenior Applications AdministratorCommented:
This may work for you.  Though you would need to put some sort of delimiter on each page where you want it to break.

http://www.vbaexpress.com/kb/getarticle.php?kb_id=922
0
GrahamSkanRetiredCommented:
This is an attempt to tailor a solution to fit your sample document.
Sub PageThree()
    Dim rng As Range
    Dim rngStart As Long
    Dim rngEnd As Long
    Dim doc As Document
    Dim d As Integer
    Set rng = ActiveDocument.Range
    Do While True
        With rng.Find
            .Text = "LOFIT Interest: N"
            If .Execute Then
                rngStart = rng.Paragraphs.First.Range.Start
                If .Execute Then
                    rngEnd = rng.Paragraphs.First.Range.Start
                    rng.Start = rngStart
                    rng.End = rngEnd
                Else
                    rng.End = ActiveDocument.Range.End
                End If
                Set doc = Documents.Add
                rng.Copy
                doc.Range.Paste
                d = d + 1
                doc.SaveAs "C:\MyFolder\" & "MyDoc" & d & ".docx"
                doc.Close
                If rng.End = ActiveDocument.Range.End Then
                    Exit Do
                End If
            Else
                Exit Do
            End If
        End With
        rng.Start = rngEnd
        rng.End = ActiveDocument.Range.End
    Loop
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.