A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Split document



 
 
Thread Tools Display Modes
  #1  
Old October 31st, 2005, 04:37 PM
KirstieA
external usenet poster
 
Posts: n/a
Default Split document

Hi all,

I have a 300 page document that i want to save in 100 3 page documents, so
every 3 pages is a separate file.

I have the following macro that does it for each individual page but don't
know how to change it for every 3 pages.

--------------------------------------------------------

Sub SplitByPage()

Dim mask As String
Letters = ActiveDocument.Bookmarks("\page").Range
mask = "ddMMyy"

Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter Letters
Application.ScreenUpdating = False
sName = "LA Notification - Appointment of Carer"
Docname = "C:\My Documents\Test\Merge\" _
& sName & " " & LTrim$(Str$(Counter))
On Error GoTo oops:
ActiveDocument.Bookmarks("\page").Range.Cut
Documents.Add
With Selection
.Paste
.EndKey Unit:=wdStory
.MoveLeft Unit:=wdCharacter, Count:=1
.Delete Unit:=wdCharacter, Count:=1
End With
ActiveDocument.SaveAs FileName:=Docname, _
FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Application.ScreenUpdating = True
Wend
oops:
End Sub

--------------------------------------------

Can anyone help??

Kirstie


  #2  
Old October 31st, 2005, 05:30 PM
Doug Robbins - Word MVP
external usenet poster
 
Posts: n/a
Default Split document

The following, run when the 300 page document is the activedocument should
do what you want:

Dim i As Long, j As Long, Source As Document, Target As Document, myrange As
Range
Set Source = ActiveDocument
Selection.HomeKey Unit:=wdStory
For i = 1 To 100
Set Target = Documents.Add
Source.Activate
j = 1
For j = 1 To 3
Set myrange = Selection.Bookmarks("\page").Range
Target.Range.InsertAfter myrange
myrange.Delete
Next j
Target.SaveAs "C:\test\Document" & i
Target.Close
Next i

If however it happens that each of the 3 pages in the 300 page document are
separated by a Section break, as happens when a formletter type mail merge
is executed to a new document, then you could use:

Dim i As Long, Source as Document, Target as Document, Letter as Range
Set Source = ActiveDocument
For i = 1 to Source.Sections.Count
Set Letter = Source.Sections(i).Range
Letter.End=Letter.End-1
Set Target = Documents.Add
Target.Range=Letter
Target.SaveAs FileName:="Letter" & i
Target.Close
Next i


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"KirstieA" (no spam) wrote in message
...
Hi all,

I have a 300 page document that i want to save in 100 3 page documents, so
every 3 pages is a separate file.

I have the following macro that does it for each individual page but don't
know how to change it for every 3 pages.

--------------------------------------------------------

Sub SplitByPage()

Dim mask As String
Letters = ActiveDocument.Bookmarks("\page").Range
mask = "ddMMyy"

Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter Letters
Application.ScreenUpdating = False
sName = "LA Notification - Appointment of Carer"
Docname = "C:\My Documents\Test\Merge\" _
& sName & " " & LTrim$(Str$(Counter))
On Error GoTo oops:
ActiveDocument.Bookmarks("\page").Range.Cut
Documents.Add
With Selection
.Paste
.EndKey Unit:=wdStory
.MoveLeft Unit:=wdCharacter, Count:=1
.Delete Unit:=wdCharacter, Count:=1
End With
ActiveDocument.SaveAs FileName:=Docname, _
FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Application.ScreenUpdating = True
Wend
oops:
End Sub

--------------------------------------------

Can anyone help??

Kirstie



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
split document onto two screens wilsontljr General Discussion 1 June 30th, 2005 05:22 PM
How do I split a large document for printing? Marilyn L General Discussion 1 May 22nd, 2005 12:04 AM
split large Word 2002 document DRDC Tech General Discussion 0 January 13th, 2005 03:15 PM
Document Merge Issues Barb Reinhardt General Discussion 1 October 13th, 2004 10:59 AM
Bookmarks are not retained during Mail Merge Latha Mailmerge 22 June 16th, 2004 08:53 PM


All times are GMT +1. The time now is 07:06 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.