Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Posts
    1,418
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi All,
    I have a document that is in excess of 200 pages. What I need to do is "break up" the document into 200+ documents, each one being a page of the former larger document.
    Any ideas or VBA to accomplish this?
    Thanks in advance.
    Jeff

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Some code examples and links have been posted in the past, mostly in the context of splitting the results of a mail merge into separate documents. Mail merges conveniently separate the individual documents with section breaks, so if your document matches that pattern, you might be able to use these solutions "as is." If not, more complex code may be required. Please see:

    [topic=663700]Mail Merg (2000)[/topic]
    [topic=772220]Word 2007 mail merge[/topic]
    [topic=647516]Macro to split large doc by Heading 2 (Word 2003)[/topic] (very long...)

    Do any of those help?

  3. #3
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    The following code should do what you need, with the following caveats:

    - It won't bring across anything in the header or footer
    - This will create a new document for each page, with each document based on the Normal template. If the document you need to split up is based on any other template, then you need to specify the name and path of that template, in the Documents.Add statement.

    Code:
    Sub CopyDocByPages()
    
       Dim PageCt As Long
       Dim n As Long
       Dim TempDoc As Document
       
       Application.ScreenUpdating = False
       'Get number of pages in document:
       PageCt = ActiveDocument.Range.Information(wdActiveEndPageNumber)
       'Loop through each page in doc, copy it, and
       'create new doc based on that page:
       For n = 1 To PageCt
          Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=CStr(n)
          ActiveDocument.Bookmarks("\page").Range.Copy
          Set TempDoc = Documents.Add
          TempDoc.Range.Paste
          TempDoc.SaveAs "Page " & CStr(n)
          TempDoc.Close
          Set TempDoc = Nothing
       Next 'n
       Application.ScreenUpdating = True
    
    End Sub
    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •