Link to home
Start Free TrialLog in
Avatar of Sonia Meskine
Sonia Meskine

asked on

Making multiple files from one file in MO word

Hello everyone,

i would like to ask for help here. I work with the attached file. And I need to separate each 2 pages, so I am going to have instead of 1 file with 356 pages but 178 files with 2 pages. Is it possible in some way ? I tried almost everything, but as I am an IT newbie I've been lost since I started. In case you found a way, please tell me or navigate me as the stupidest person on the Earth.


thanks very much
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

You didn't succeed in attaching the document, but if you have described the problem well, it isn't necessary.

Here is some VBA code that should do the job, It produces a document for every two pages in the original. The new document names are suffixed with a three-digit  number.

Sub SplitDoc()
Dim p As Integer

Dim rng As Range
Dim rngStop As Range
Dim docA As Document
Dim docB As Document
Dim iPages As Integer

'Set docA = Documents.Open("I:\Allwork\ee\29115599\BigTest.docx") 'my test file
Set docA = ActiveDocument

iPages = docA.Range.Information(wdNumberOfPagesInDocument)
p = 1
Do
    Set rng = docA.GoTo(wdGoToPage, wdGoToFirst, p)
    p = p + 2
    If p > docA.Range.Information(wdNumberOfPagesInDocument) Then
        p = docA.Range.Information(wdNumberOfPagesInDocument)
    End If
    Set rngStop = docA.GoTo(wdGoToPage, wdGoToFirst, p)
    rng.End = rngStop.Start
    Set docB = Documents.Add
    rng.Copy
    docB.Range.Paste
    docB.SaveAs Replace(docA.FullName, ".doc", "_" & Format((p - 1) / 2, "000") & ".doc")
    docB.Close
Loop Until p = docA.Range.Information(wdNumberOfPagesInDocument)
End Sub

Open in new window

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.