Folks,

I am trying to determine programmatically the length (in inches, pixels or
any distance measure) of a given text selection (or line). For example:
THE QUICK BROWN FOX. . when typed in capitalized letters takes more
screen space than.
the quick brown fox . when typed in lower caps. Also, the bold version
of it
the quick brown fox .takes a little more screen space than the non-bold
version..


The above is also true for text strings containing different characters. For
example:
Mmmmmmmmmm . takes more screen space than
iiiiiiiiii


So far I know how to get the length of a selected text (in characters) using
the following line:

Selection.Characters.Count

Can someone tell me how to get the length (distance) of a given text line in
the screen ? I don't care if it is in inches, pixels, or centimeters.

Thanks in advance.

JOCA

Re: An easy question (hopefully) about text length. Thanks! by Madhukar

Madhukar
Sat Jul 05 02:17:54 CDT 2003

HI JOCA,

you prblem is not clear.
You want to get the distance of you text in screen or from
some location of document.
coz measuring distance in screen and in document is
different.
With regrds madhukar



>-----Original Message-----
>(Since this newsgroup seems more appropriate
than .Customization, let's
>continue here)
>
>> Can someone tell me how to get the length (distance) of
a
>> given text line in the screen ?
>
>Hi JOCA,
>
>Look up the Information property in the VBA help.
>But: What do you need that information for? There might
be an easier way
>(for example to fit text to a certain width).
>
>Greetings,
>Klaus
>
>.
>

Re: An easy question (hopefully) about text length. Thanks! by Helmut

Helmut
Sat Jul 05 04:36:12 CDT 2003

Hi Joca,
you might try this:
Select the text.
Start a Makro that:
1. puts the text in a variable
2. collapses the cursor to the left.
3. Get Selection.Information(7) ' eg. into pos1
4. search for the text
5. Collapse the cursor to the right.
6. Get Selection.Information(7) ' eg. into pos2
pos2 - pos1 is the width of the selection,
if the selection restes on one (!) line.
pos2 - pos1 is the textwidth in Twips
20 Twip = 1 Point, 72 Point = 1 Inch
Greetings from Bavaria, Germany
Helmut Weber
(using Word 97)
wdHorizontalPositionRelativeToTextBoundary = 7 !!!