PDA

View Full Version : identify break in table



barcon
09-26-2004, 07:23 AM
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

Bilby
09-26-2004, 02:55 PM
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.

TonyJollans
09-26-2004, 04:17 PM
Hi Barbara,

Welcome to VBAX!

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

ActiveDocument.Tables(4).Range.ComputeStatistics(wdStatisticPages)

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.

barcon
09-27-2004, 07:13 PM
To determine the number of pages a table spans you can use ComputeStatistics:

ActiveDocument.Tables(4).Range.ComputeStatistics(wdStatisticPages)

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