Width of a text in a cell

D

Doug Robbins - Word MVP

Hi Karine,

This can be done with the use of the
Selection.Information(wdHorizontalPositionRelativeToPage) function applied
to the beginning and end of the text. The width will be the difference.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
H

Helmut Weber

Hi Karine,
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
' wdHorizontalPositionRelativeToTextBoundary = 7 !!!
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.
If the selection spans over more than one line,
it's becoming still more complicated.
pos2 - pos1 is the textwidth in Twips
20 Twip = 1 Point, 72 Point = 1 Inch
There are other methods, that could vary in detail,
though, it's never quite simple and straightforward.
Greetings from Bavaria, Germany,
Helmut Weber
 
K

Karine

Hi !
The problem is that my text comes from a mergefield. This mergefield is in a cell.
How can i select this mergefield?
I am a beginner in VBA...
 

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