Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Posts
    122
    Thanks
    7
    Thanked 0 Times in 0 Posts

    How to Delete Report Headings and Footers (Word 2K/XP VBA)

    I have to delete page headings and a footer for a weekly report I do not create. I receive the report as an rtf document. The report is currently over 60 pages and growing. I need to delete all heading and footer lines to create a document that contains only detail lines.

    The header and footer are hard lines in the document, not word Header / Footer records. To complicate matters the header can change slightly from week to week and the footer contains the date and page x of y so each footer is unique. The first page includes 2 report headings that are not repeated on the following pages and the final page contains some total lines that I would also like to delete in a macro.

    I have worked with Access VBA but never Word VBA before so my attached attempt is crude.

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: How to Delete Report Headings and Footers (Word 2K/XP VBA)

    Hi,

    If your header and footer always have certain information that is unique to them then, even though part of each changes, you may be able to incorporate the unigue text and wildcards into your search/replace parameters.

    You then wouldn't need to have the kind of code you have for finding the first header and footer - they'll be treated just the same as all the others. On the other hand, if the headers and footers have enough variablitity to justify it, you may be able to copy x characters from each and place them into your search/replace parameters.

    Cheers

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Posts
    122
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Re: How to Delete Report Headings and Footers (Word 2K/XP VBA)

    As always the Devil is in the details. How do I format a VB Find to include wildcards? How can I tell when I have reached the end of a document? How can I define a search string that starts with a known text string and ends with a special character like a line break or page break?

  4. #4
    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: How to Delete Report Headings and Footers (Word 2K/XP VBA)

    To develop your Find syntax, it often is easiest to turn on macro recording and experiment interactively.

    You might find that the more restrictive rules for wildcard searches don't allow you to do it all in one step. In that case, you can use methods of the Selection object to extend to the character of interest.

    To loop a search, you generally set up the Find parameters, and then do something like this:

    Do While Selection.Find.Execute
    'take action
    Loop

    There have been some examples posted recently. Hope this helps.

Posting Permissions

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