Splitting a large .doc file

  • Thread starter Глеб Чебриков
  • Start date
Ð

Глеб Чебриков

Dear group members,

there is a certain problem, the specific solution to which I still
haven't found on any site. I am presently working on a 270 page
document in Microsoft Word, which causes me trouble because I need to
split it in several files, each having 50 pages. Copying and pasting
is not the best solution, and I know that this operation can be
carried over much easier with the help of a macros. There are several
variants on the Net, but I can't find the one that would split the
large file by 50 pages.

With this in mind, could you please help me by posting the necessary
macros and telling how to set the necessary number of pages (50 or
some other number) in it?

Respectfully.
 
T

That Guy

Try this:


Public Sub BreakUp()

Dim aDoc As Document
Dim breakDoc As Document
Dim currentPageCount, Counter As Integer
Dim x As Integer
Dim Name As String
Dim BreakUpNumber As Integer

currentPageCount =
ActiveDocument.ComputeStatistics(wdStatisticPages)
Set breakDoc = ActiveDocument

BreakUpNumber = 3

Selection.HomeKey Unit:=wdStory

Counter = 1

If currentPageCount Mod BreakUpNumber > 0 Then
MsgBox "The Document must be divisible by the breakup number",
vbCritical, "Wait"
Else

While currentPageCount > Counter

Name = Mid(breakDoc.Name, 1, Len(breakDoc.Name) - 4) & "
Pages " & CStr(Counter) & " - " & CStr(Counter + 2) & ".doc"
Counter = Counter + BreakUpNumber

Set aDoc = Application.Documents.Add

For x = 1 To BreakUpNumber
breakDoc.Activate
ActiveDocument.Bookmarks("\page").Range.Cut
aDoc.Activate
Selection.EndKey wdStory
Selection.PasteAndFormat wdPasteDefault
Next x

aDoc.SaveAs Name
aDoc.Close

Wend

End If


End Sub

This seems to work with my test document that was 9 pages long. Each
of the smaller documents may contain an extra blank page. Also there
is no error trapping other than being sure the number of pages you are
trying to break out each time is a divisor of the documents total
pages.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top