Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / General MS Word Questions / October 2005

Tip: Looking for answers? Try searching our database.

Split document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
KirstieA - 31 Oct 2005 17:37 GMT
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
Doug Robbins - Word MVP - 31 Oct 2005 18:30 GMT
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

Signature

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

> Hi all,
>
[quoted text clipped - 42 lines]
>
> Kirstie
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.