I am sorry but...
"Can anybody tell me if I can detect a break before detecing the end of table, if the table crosses the break boundry?"
Cracked me up. Ah.....that is the crux of the matter, is it not? Your success on this rather hangs on the answer.
Good luck! No offence intended, but I am afraid you are not quite grasping the object model regarding tables in Word. Nor the overhead required to do all the repagination you MUST do (every time you make any change at all!).
Is what you are wanting to do impossible? Ummmmmmmm.......no.
However, it
will will will will take a LOT of coding and processing and is - unless you can seriously convince me otherwise - an exercise in potential frustration beyond the value returned.
But, if you get it working, I guarantee you will know a lot more about how Word deals with ranges and tables!
and check if it breaks a page. I have a 240 tables so it looks like a bunch of repaginations and checks.
Those 240 wil take a while. Plus the very fact you say breaks a page indicates a misunderstanding. A table never breaks a page.
BTW: technically speaking, if you break up a table (making two tables) that crosses a page boundary then your statement "Table continued" is a falsehood.
From Words perspective the table is NOT continued. You may say it does, but this (as least from Word) is not true.
And that is the issue. You are thinking Word thinks the same way as you. It does not think at all. It has an object model. It is software. And no,
firm belive that you can do anything with software
that is a falsehood. You can not do anything with software.
Software MUST work within its object model. You can NOT make software do anything contrary to its object model. True, the more one understands the object model the more you can make software dance through hoops not normally used.
Which is why I say is this impossible. Ummmmmmmm...no.
I am trying to decide whether to give you some starting help, or not. Ok.
Make a table with enough text
in the first cell that it flows onto the next page. Are we clear?
Row1 on page 4
and continues onto page 5.
Row2 is on page 5.
WHERE are you going to make a forced break? Because not only does a table flow onto a following page, but the
cell range does as well.
Can you detect is a given row is on a following page (say from the page the table starts on)? Yes. Here is my starting hint/help.
Code:
Sub WhatAMess()
Dim r As Range
Dim tblStartPage As Long
Dim oTable As Table
Dim oTableRange As Range
Dim oRow As Row
Dim msg As String
' get the page os the start of the table
Set oTable = ActiveDocument.Tables(1)
Set oTableRange = oTable.Range
oTableRange.Collapse 1
tblStartPage = _
oTableRange.Information(wdActiveEndAdjustedPageNumber)
' loop through each row checking if it is the same page
For Each oRow In oTable.Rows
Set r = oRow.Range
r.Collapse 1
If r.Information(wdActiveEndAdjustedPageNumber) <> _
tblStartPage Then
msg = "Row " & oRow.Index & " is AFTER the page break."
GoTo tellme:
End If
Next
tellme:
MsgBox msg
End Sub
My tables have no headers and if they did it would just be PN, DESCRIPTION and PRICE but I have concluded that that info is understood.
Perhaps it is understood...then WHY do you need a "Table continued"?????? If your users are knowledgeable to understand the first, do you not think they can see/figure out the table has continued?
Hmmmm?
"I am a glutten for punishment "
Yes sir, you are. One part of me is giving you a bravo though. Good luck!
Gerry