I need to find the cell position in points relative to the top of the page. My problem is that the table spans multiple pages and has vertically merged cells which may cross page boundaries. The pages also have a header and footer on them. For a "non-complex" table (no merging of cells), the following gives me what I want:
Dim myTable As Table
Dim myCell As Cell
Dim iRow, iCol, myPosition As Integer
Set myTable = ActiveDocument.Tables(1)
Set myCell = myTable.Cell(iRow, iCol)
myCell.Range.Select
Set myRange = Selection.Range
Selection.Collapse Direction:=wdCollapseStart
myPosition = myRange.Information(wdVerticalPositionRelativeToPage)
But if my table has vertically merged cells, then the information inquiry gives erroneous results. Example - the table below is split across 2 pages where rows 1 through 5 are on the first page and rows 6 and 7 are on the second page. I need to find the vertical position in points relative to the top of the page of a cell in row 6. Even if I select an unmerged cell, say row 6, col 3 I still get bogus results. Any way around this?
Horizontally merged header: Row 1, Column 1 |
R2, C1
|
Row 2, Col 2
|
Row 2, Col 3
|
R2, C4
|
R2, C5
|
R2, C6
|
Row 2, Col 7 - Horizontally merged
|
Row 3,
Col 7 |
R3, C8
|
R3, C9
|
R3,C10
|
R3, C11
|
R3, C12 |
R4,
C1
V
E
R
T |
R4, C2 |
Row 4, Col 3 |
R4C4 |
|
|
|
|
|
|
|
|
Row 5, Col 2 |
Row 5, Col 3 |
R5C4 |
|
|
|
|
|
|
Last Unsplit |
LAST Split
R5, C12 |
Row 6, Col 3 |
R6C4 |
|
|
|
|
|
|
|
Notes: Horizontally merged cells: Row 7, Col 1 |