Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: Check if a paragraph fits into a cell without "breaking" its height.

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Check if a paragraph fits into a cell without "breaking" its height.
"GD1" <euthymos[ at ]gmail.com> 26.09.2006 17:57:41
How can I check if a paragraph fits into a cell without "breaking" its
height using VBA?

Thank you!

Re: Check if a paragraph fits into a cell without "breaking" its height.
Cindy M. <C.Meister-C[ at ]hispeed.ch> 28.09.2006 07:37:52
Hi Gd1,

[Quoted Text]
> How can I check if a paragraph fits into a cell without "breaking" its
> height using VBA?
>
Not easily, if at all. The .Information property of the Range/Selection
objects does provide a way to get the RelativeHorizontal position of a
"point". So you could get that from the end and start points, calculate
the difference, and compare it to the available cell width less cell
padding. But it's not *guaranteed* to work exactly. And if different
fonts are applied in the two places, all bets are off.

The better approach would probably be to put the paragraph into the cell
then count the number of lines.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :-)

Re: Check if a paragraph fits into a cell without "breaking" its height.
"GD1" <euthymos[ at ]gmail.com> 29.09.2006 06:04:48

[Quoted Text]
> The better approach would probably be to put the paragraph into the cell
> then count the number of lines.

I thought the same. Counting the lines is the best solution. But how
can I know how many points is tall, for example, one line of Verdana
7pt?

Thank you!

Re: Check if a paragraph fits into a cell without "breaking" its height.
"GD1" <euthymos[ at ]gmail.com> 29.09.2006 06:04:52

[Quoted Text]
> The better approach would probably be to put the paragraph into the cell
> then count the number of lines.

I thought the same. Counting the lines is the best solution. But how
can I know how many points is tall, for example, one line of Verdana
7pt?

Thank you!

Re: Check if a paragraph fits into a cell without "breaking" its height.
"Robert M. Franz (RMF)" <robert.franz[ at ]mvps.org> 30.09.2006 21:16:45
GD1 wrote:
[Quoted Text]
> I thought the same. Counting the lines is the best solution. But how
> can I know how many points is tall, for example, one line of Verdana
> 7pt?

The easiest way seems to be to _define_ an exact line heigt for the
paragraph.

HTH
Robert
--
/"\ ASCII Ribbon Campaign | MS
\ / | MVP
X Against HTML | for
/ \ in e-mail & news | Word

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net