Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Oct 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Universal Macro for Doc Library (Word 2003)

    I need help with a macro dilemma. I have a library of 300+ documents that are built on the same template with 7 identical section headings in each document. The documents vary in total length and also in the length of the 7 sections. I need to develop a single macro that can be applied to all 300+ documents that will enable the user to select from a toolbar or dialog box which sections they would like to remove from the document. I can create the toolbar/dialog box, but I'm not sure how to approach the removal of the text because I don't want to go into all the documents to set up bookmarks. Is there an easier solution?

    Any help will be greatly appreciated.
    JeffA

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

    Re: Universal Macro for Doc Library (Word 2003)

    If the sections are sections in the Microsoft Word sense, that is if they are separated by section breaks, you can delete a section relatively easily:

    ActiveDocument.Sections(3).Range.Delete

    will delete the 3rd section from the document. You have to be careful if the individual sections have different page settings, headers or footers.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Universal Macro for Doc Library (Word 2003)

    If you don't have actual sections, but you have consistent sytle formatting (e.g., Heading 1, then any number of body, Normal, etc., then another Heading 1), VBA can select from one Heading 1 to the next, back off a bit, and clear out the selection. I don't remember exactly how you expand the selection using a style name, but I've seen the code posted here (the post was in the context of selecting backwards to the last heading of a particular level). You still would need the user's input on which of the identical section headings is the relevant one...

  4. #4
    New Lounger
    Join Date
    Oct 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Universal Macro for Doc Library (Word 2003)

    Hans,
    Thanks for your response, but unfortunately there are no section breaks, and because these documents are actually sub-documents that are added to a main template in mail merge, I'm afraid adding the breaks would create the problems in the template page settings (as you point out).

    Jeff

  5. #5
    New Lounger
    Join Date
    Oct 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Universal Macro for Doc Library (Word 2003)

    jscher,
    Thanks! I think that might actually work. I'll look for the code you suggested.
    Jeff

Posting Permissions

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