Reputation: 31
I need to calculate the left and top coordinates of a table cell.
At work we have been developing an Add-In in VBA for Microsoft Word to turn Word documents into fillable PDF forms. All fields are to be inserted inside table cells, so it is the exact location of the table cells (left and top relative to the page) that are necessary for the placing of the data fields.
To get the vertical position of the top of a cell relative to the upper leftmost corner of the page we have tried:
Tables(n).Cell(row,column).Range.Information(wdVerticalPositionRelativeToPage)
The results exceed the table Top position by about 5 points at the top of the page. The excess is reduced as you go down the page. In cells located about the end of the page the result is spot on.
To get the horizontal position relative to the upper leftmost corner of the page we have tried:
Tables(n).Cell(row,column).Range.Information(wdHorizontalPositionRelativeToPage)
The results are incorrect. The results point to Left of the Table (not of the cell) plus about 3 points.
We have tried setting the table to Fixed Column Widths, and varying the zoom from 100% to fit to Window. No luck.
Any suggestions how to get the correct vertical (top) and horizontal (left) positions of a cell?
Upvotes: 0
Views: 383