none
VBScript - Identifying Rows that are too large for a page RRS feed

  • Question

  • I have tables in MS Word, and I am trying to see what the height of a row is in that table.  As the tables are, the Rows HeightRule is set to Auto (wdRowHeightAuto).  From what I have noticed the Height of the Rows are set to 9999999 points when the HeightRule is Auto.  And when I convert the rows to wdRowHeightAtLeast, the Height is changed to 12 points regardless of the content of the cells in that row.

    Overall question,

    Is there any way to read the actual height of the row as opposed the "at least" value?

    OR

    Is there a way to identify if a row should be allowed to break across a page when AllowBreakAcrossPages is set to True?

    Note:

     I tried setting the HeightRule to wdRowHeightExactly, all that did was make the rows have a height of 12 points.  If at all possible I would like to get a script working to do this for me as opposed to manually like I have been.

    Wednesday, October 22, 2014 5:07 PM

All replies

  • Correction in the question.

    "Is there a way to identify if a row should be allowed to break across a page when AllowBreakAcrossPages is set to False?"

    The goal is to set the rows to True as needed, not just a massive set every row to True. 

    There was a typing mistake in the original question. My apologies.

    Wednesday, October 22, 2014 5:11 PM
  • What is the issue with allowing all rows to break across pages? Trying to manage this on a row-by-row basis is fraught with difficulty in a document that's still subject to editing and/or may be viewed/printed from a PC using a different printer/print driver (because Word uses data from the active printer's driver to optimise layout).

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Thursday, October 23, 2014 12:29 AM
  • If your question relates to a highly structured document that does not allow rows to break across tables, content in a table cell can become hidden beneath the bottom margin of the page. To programmatically solve this you need to know the last position a table row relative to the top of the page and you need to know the bottom margin of the page, also relative to the top of the page.

    To compute the bottom margin position you need to know the paper size and orientation and of course the bottom margin setting and with a bit of math you store that number as a single in inches or centimeters.

    To find the relative position of the last character in a table row that is determining the height of the row, you have to either know which cell that probably is, or loop thru each cell in the row and compare the last positions. What you are looking at is either Selection.Information(wdVerticalPositionRelativeToPage) or its Range counterpart command. The value returned will be in points and if you are interrogating the last character of each cell, the winner is the largest number.

    With the character position of the cell that's determining the rows height you now convert that to your measurement system Application.PointsTo... and compare the result to your stored bottom margin position. If it's equal to or greater than the bottom margin position you apply the "Allow to Break Across Pages" option to the row.

    Hope this helps.


    Kind Regards, Rich ... http://greatcirclelearning.com

    Thursday, October 23, 2014 2:59 AM