Width of a text in a cell 
Author Message
 Width of a text in a cell

I'd like to know the width(in points) of a text in a cell? Is it possible?
Thanks


Sun, 01 Jan 2006 17:32:42 GMT  
 Width of a text in a cell
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


Sun, 01 Jan 2006 18:15:57 GMT  
 Width of a text in a cell
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

Quote:
> I'd like to know the width(in points) of a text in a cell? Is it possible?
> Thanks



Sun, 01 Jan 2006 18:14:33 GMT  
 Width of a text in a cell
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...


Mon, 02 Jan 2006 01:56:17 GMT  
 Width of a text in a cell
Hi Karine,
to determine the text-width in a mergefield would mean,
merge all and process all. That's hell. Could be done,
but, forgive me, forget it. It's jumping from the frying
pan into the fire. What will You do with the result that
texts of mergefields 129, 300, 301 and 334 do not fit into
the cell?
Greetings from Bavaria, Germany
Helmut Weber


Mon, 02 Jan 2006 18:23:37 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Text Width of Cell Data in Excel/VBA?

2. Cell.Width and Cell.RowIndex Bug?

3. VB5: MSFlexGrid: Setting the Width of a cell based upon text within the cell.

4. Column/Cell Widths In HTML Tables

5. MSFlexGrid : How to increase Cell Height and Width?..

6. Width of text in a text box

7. Width of text in a text box

8. a text cell like text control

9. Output to a fixed-width text file

10. Access97: How to determine width of text when NOT in report event

11. Access 97: How to determine width of field bound to text box

12. Importing Fixed-Width text files

 

 
Powered by phpBB® Forum Software