Home > OS >  Word VBA: Determining Left and Right Table Boundary Position
Word VBA: Determining Left and Right Table Boundary Position

Time:12-01

I am stumbling over something that I feel should be very simple.

I need to know the left and right boundary position of a table. I've tried various combinations of Selection.Information(wdHorizontalPositionRelativeToPage), but that appears to actually give me the position of text within the table, and hence is dependent on cell padding and left/center/right justification. Essentially what I want is the left and right table border position.

I've been VBAing for a couple of hours now, and it seems like this should be very simple. (For instance, the table knows where to draw it's boundaries...)

Thanks in advance!

CodePudding user response:

You need to get the position of the table's range not the selection.

ActiveDocument.Tables(n).Range.Information(wdHorizontalPositionRelativeToPage) will give you the position for a specific table.

Selection.Tables(1).Range.Information(wdHorizontalPositionRelativeToPage) will give you the position for the table that contains the selection.

  • Related