Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Macro to split large doc by Heading 2 (Word 2003)

    I have a large document that I would really like to break into individual documents. 20 to be exact. It may seem silly but I want it to break into individual documents from Heading Level 2. The main document has one big long TOC. A wish come true would be for the document to be broken down and for each new doc to have its own TOC.

    Is this possible?

    Kerry

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    Does your document also have Heading 1 paragraphs? How should those be treated?

  3. #3
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    Yes there is a heading 1. This is the document title. I would like to disregard this Heading leve.

    Kerry

  4. #4
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    Or on second thoughts, Heading one (the Title) could be at the top of each of the subsequent documents.

    Kerry

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    Here is a relatively simple way to split your document:
    - Make a backup copy of the document.
    - Switch to Outline view.
    - On the Outlining toolbar, select Show Level 2 from the Show Level dropdown.
    - Select all Header 2 paragraphs.
    - Click 'Create Subdocument' on the Outlining toolbar.
    - Save your document. Word will automatically create a separate document for each Heading 2.

  6. #6
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    My document has 20 chapters with which all start with Level 2 headings. (195 pages) I tried your suggestion and it takes a long time to select each Level 2 heading and it just names the file 1, 2 3 etc. and the docs it creates just have the heading and no text.

    I was hoping for something that would be very quick and name the file the same name as the Heading as I will be running this quite a lot. The main document has one large TOC at the beginning. Ideally the split docs would have their own TOC.

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    > as I will be running this quite a lot

    Wouldn't it be easier to set up the documents correctly from the start, instead of creating a problem and then trying to find a way out of it?

  8. #8
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    I agree with your thoughts. Perhaps I need to give you a bit of background.

    I originally developed this series of documents at you suggest. Individual files for each chapter and Tables of contents etc. It was all linked by one file which linked it all together. It ends up being 13mb in total size. This makes a manual. I have never been able to post it to our Intranet due to the size and the clumsy way it would be accessed.

    After a lot of searching I found a product that converts all documents into XML format with a TOC. It ends up being very nice for the intranet. The product is Republico - XDK. It also creates one document containing all the chapters with one big TOC at the beginning. I want to be able to allow the user to not only be able to view the content online, but to be able to print the particular chapter should they wish. I dont want them to print the whole 195 pages at the click of the button.

    So what I want to do is split the document and put a button on each Heading 2 Frame to print the document. This is where I need the topic name to be the file name. If it always keeps the same name the button reference will always be correct.

    Does this info help give you an idea of my issue?

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    I would have published each chapter as a separate intranet document...

    I'll be offline for several hours; if nobody else comes up with an idea in the meantime, I'll look at it when I come back.

  10. #10
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    That wasnt possible as there are links between chapters and our bandwidth didnt allow such big documents. Trust me I had my reasons to go to this program.

  11. #11
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro to split large doc by Heading 2 (Word 2003)

    <P ID="edit" class=small>(Edited by wdwells on 29-Apr-07 08:34. )</P>Assuming your headers and footers are consistent throughout the document, it should be a relatively simple task to create a template based on your intended layout, then create a macro to:
    1. <LI>copy each group of paragraphs that begin with a level 2 heading and end where the next paragraph is either a level 2 heading or the end of the document;
      <LI>open a new document based on the template which you created;
      <LI>paste the clipboard into the new document;
      <LI>set the numbering to start at the appropriate spot;
      <LI>save the new document in accordance with your naming scheme;
      <LI>close the new document;
      <LI>return to step 1
    You may come unglued if there are cross references between chapters that have not been changed to hard text.
    HTH
    Regards
    Don

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    Cross references between the chapters change the situation. I'd dump the idea of Word documents altogether and switch to web pages (HTML).

  13. #13
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    Just trust me Hans, I do have a need to split a large document. Can you help me with this please?

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    The attached document contains a macro that will create a new document for each Heading 2 paragraph. Everything before the first Heading 2 paragraph will be copied into each new document; this should include the title and the TOC. The name of the documents will be taken from the Heading 2 paragraphs.
    I have provided the code with a lot of comments. It could be made a bit more elegant, but let's see whether it does what you want first. You can test the macro on the document itself.
    Attached Files Attached Files

  15. #15
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Macro to split large doc by Heading 2 (Word 2003)

    Hans it is wonderful! Thankyou.

    I am having just one minor problem. My styles seem to be changing when it I do the split. Not sure why.

Page 1 of 2 12 LastLast

Posting Permissions

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