Cell height when text is wrapped

F

Francis Hookham

1
Rows in the third column of table pasted into Word 2000 from XL has text
wrapped in many cells but the (row) height of the individual cells does not
always equal what it should be for the number of wrapped rows of text in the
cell. Often even a single row cell is deeper that it should be

Can anyone suggest a macro which would check how deep a cell should be for
the amount of wrapping and set the row accordingly

I have to do this regularly and it is tedious manually dragging each row to
suit - Office 2000 on this PC but could use 2002 on laptop

2
How does one write a while/wend to run down the third column - is there a
way of
determining how many rows there are?

Francis Hookham

PS
I posted this question to the microsoft.public.word.programming newsgroup
two weeks ago but no one has responded
 
J

Jezebel

1. This is actually quite tricky. (And if you trawl the archive you'll see
that you're not the first to ask.) You can use the Information() property to
check your vertical position on the page: so test the first and last words
in the cell, then adjust the row height to accommodate the difference.

2. While ... Wend is kind of obsolete. Do ... Loop is a better construction.
If your table is uniform (no merged or split cells), you can use For ...
Next also ---

For pRow = 1 to Table.Rows.Count
Set pCell = Table.Cell(pRow, 3)
:
Next

If you know nothing about the structure of the table, use something like

Set pCell = Table.Cell(1,1)
Do
if pCell.ColumnIndex = 3 then
... we're in column 3
end if
set pCell = pCell.Next
Loop until pCell is nothing
 
J

Jean-Guy Marcil

Francis Hookham was telling us:
Francis Hookham nous racontait que :
1
Rows in the third column of table pasted into Word 2000 from XL has
text wrapped in many cells but the (row) height of the individual
cells does not always equal what it should be for the number of
wrapped rows of text in the cell. Often even a single row cell is
deeper that it should be
Can anyone suggest a macro which would check how deep a cell should
be for the amount of wrapping and set the row accordingly

I have to do this regularly and it is tedious manually dragging each
row to suit - Office 2000 on this PC but could use 2002 on laptop

Have you tried simply selecting the whole table, then get to the table
properties dialog?
On the row tab, set the rows to a height "At least" of a value of 12 points
(or whatever represents the font size in the table).

Normally, when you set the row height to "At least" smaller then needed, you
should not get any empty space at the end of the cell, unless there are
empty ¶ in the cells, a single ¶ just before the ¤ (end of cell marker) or
another cell in the same row that contains more text.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
F

Francis Hookham

Merci - the following does it nicely

Sub CheckRowHeight()
Application.ScreenUpdating = False
Selection.Tables(1).Select
Selection.Rows.Height = wdRowHeightAtLeast
Selection.Rows.Height = InchesToPoints(0.01)
Selection.HomeKey Unit:=wdStory
End Sub
 

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