How to get the Height of a table

C

chenfeng

I use the following code to read the height of "Rows" or "Cell":
Height := Table.Rows.Height
Height := Table.Rows.Item(1).Cells.Item(1).Height

The problem is that: the result value of Height is "9999999" (the value of
"wdUndefined").Can someone tell me: How to get the real Height?
Thanks very much!
 
M

macropod

Hi chenfeng,
The reason you're getting this is that the cell has no specified height.
From the Word help file:
If the HeightRule property of the specified row is wdRowHeightAuto, Height
returns wdUndefined

Cheers
 
C

chenfeng

I know the meaning of "HeightRule". But if I set the HeightRule to
"wdRowHeightAtLeast", the result height value of every Table Row is always
"12", no matter how many lines the row have. If I set the HeightRule to
"wdRowHeightExactly", the size of the table have changed greatly, which I
cannot tolerate. More ever, the row height cannot change automatically when
user input paragraphs.
So How can I read the real height of every table in the DOC document when
the table row HeightRule is set "wdRowHeightAuto ". Since the height
property is weUndefined, I think there must be some other methods.
Waitting for your Reply. Thanks very much!
 
C

Cindy M -WordMVP-

Hi Chenfeng,
So How can I read the real height of every table in the DOC document when
the table row HeightRule is set "wdRowHeightAuto ".
there's really no good way, actually. As far as Word - a word-processor
based on dynamic layout - is concerned, there is no defined table height,
it's always in flux. Best you can do is to use the .Information property to
get the position on the screen of two ranges or selections, then compute
the height. Note that the result is dependent on the document actually
being laid out on the screen, in WYSIWYG. (And even then it's not
especially accurate)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top