Consulting

Results 1 to 4 of 4

Thread: identify break in table

  1. #1
    VBAX Newbie
    Joined
    Sep 2004
    Location
    CT USA
    Posts
    2
    Location

    identify break in table

    I have invoices (25 plus) sequentially inserted as tables into Word 2000. Each invoice is formed as 4 tables, with a page break ending. The 1st table has the invoice number. The 4th has item information which may be lengthy enough to break over pages. Rows aren't allowed to break across pages.

    I would like to discover which invoices have the 4th table breaking across pages. Then I would like to paste the 1st table with the invoice info at the top of the next page. I can identify the 1st and 4th table per invoice, but I don't know how to identify which have the next page break within. After that I would need to figure out how to insert a new row above the row starting on the next page, where I will paste the table containing the invoice number.

    I will appreciate any help.

    Barbara

  2. #2
    VBAX Regular
    Joined
    Sep 2004
    Posts
    65
    Location
    Greetings,

    From VBA help you can use the information object to find the page that contains the current selection.

    MsgBox "The selection is on page " & _
    Selection.Information(wdActiveEndPageNumber) & " of page " _
    & Selection.Information(wdNumberOfPagesInDocument)

    What you can do is select table(4)'s first cell and save its page number to a variable, then do the same for the tables last cell. If they're not the same then you have a spanning table.

  3. #3
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Hi Barbara,

    Welcome to VBAX!

    To determine the number of pages a table spans you can use ComputeStatistics:

    [VBA] ActiveDocument.Tables(4).Range.ComputeStatistics(wdStatisticPages)[/VBA]

    When you have this information, I think you are going to have a lot of fun trying to add extra rows to your table. Suppose the table has broken when there is enough room for a small row on a page, but not enough room for the row which actually happens to be there. When you add a small row to include your invoice number table it might fit on the previous page. I think you might have to consider redesigning your invoice tables and/or your pages to achieve the results you want. If you need any help with this, do feel free to post again, and, perhaps, upload a sample document.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  4. #4
    VBAX Newbie
    Joined
    Sep 2004
    Location
    CT USA
    Posts
    2
    Location
    Quote Originally Posted by TonyJollans
    To determine the number of pages a table spans you can use ComputeStatistics:

    [VBA] ActiveDocument.Tables(4).Range.ComputeStatistics(wdStatisticPages)[/VBA]

    If you need any help with this, do feel free to post again, and, perhaps, upload a sample document.
    Thanks for the advice. With the information you and Bilby have given I can get started and see what works best. Can't redesign invoices, they're created from a proprietary program. Fortunately I don't have a request for this bit yet, though I anticipate one. And thanks, I will ask again if I have more problems to solve.

    Barbara

Posting Permissions

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