Word97 - row/cell height returns 99999999 etc.

R

Ricardo Smith

I want to resize a table in VBA to fit the page. But I
can't get the height of a cell/row. I just get 9999 to
infinity. (and beyond) :) Is this a bug or am I not
referencing it correctly? Heres a snippet of code.

Set oTable = Selection.Tables(1)
iCellHeight = oTable.Cell(1).Height

My plan was to loop through the table to get the table
height then rezise the the last cellso it stretches to the
bottom of the page and then do a "distribute rows" etc.
Alternative methods would be welcome.
 
J

Jonathan West

Hi Ricardo,

whet the 999999 result means is that different cells within the referenced
range return different heights.

I think there is a bug in yiour code, if you want to refer to just the first
cell on the first row, you need the following

Set oTable = Selection.Tables(1)
iCellHeight = oTable.Cell(1, 1).Height

This should work, as it is now just referring to a single cell, and not all
the cells in the first row.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
 
C

Cindy Meister -WordMVP-

Hi Jonathan,
whet the 999999 result means is that different cells within the referenced
range return different heights.
Are you sure, Jonathan? My recollection is that Word returns 999999 when you
don't have an "exact" row height specified. IOW, the row can grow with the
text you enter.

Your suggestion returns 999999 when I test it...
I think there is a bug in yiour code, if you want to refer to just the first
cell on the first row, you need the following

Set oTable = Selection.Tables(1)
iCellHeight = oTable.Cell(1, 1).Height

This should work, as it is now just referring to a single cell, and not all
the cells in the first row.


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

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