Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Calculate string width in inches nzDec01

HI all,
The worksheets in my app must be printed on paper about 7 inches wide in a
font size of at least 18 or 20 to be read in very dim lighting. Column
widths are fixed.

If a macro generated text string does not 'fit' into the designated cells
in 1 row, I use more than 1 row to hold the text after spliting it into
'words'.

I'm trying to AVOID building a function to return the width of a character
string in inches, for a few font sizes and 1 to 3 font names.

.Shrinktofit on its own doesn't seem to help.

1. I can't find a way to test, If OneCell.Shrinktofit = true then Did
Excel actually shrink the cell contents ? This would help.

2. Is a call available to MSword that returns the width in inches of a
string, where its input is the font name and size of the characters? (It's
gotta be there, but is it available to mortals? I've also posted this on the
Word bulletin board.)

3. What might other 'stuff' be that I might be able to use?

Thanks.
--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Calculate string width in inches nzDec01

Widths are tricky... Check out this link...

http://support.microsoft.com/default.aspx/kb/214123
--
HTH...

Jim Thomlinson


"Neal Zimm" wrote:

HI all,
The worksheets in my app must be printed on paper about 7 inches wide in a
font size of at least 18 or 20 to be read in very dim lighting. Column
widths are fixed.

If a macro generated text string does not 'fit' into the designated cells
in 1 row, I use more than 1 row to hold the text after spliting it into
'words'.

I'm trying to AVOID building a function to return the width of a character
string in inches, for a few font sizes and 1 to 3 font names.

.Shrinktofit on its own doesn't seem to help.

1. I can't find a way to test, If OneCell.Shrinktofit = true then Did
Excel actually shrink the cell contents ? This would help.

2. Is a call available to MSword that returns the width in inches of a
string, where its input is the font name and size of the characters? (It's
gotta be there, but is it available to mortals? I've also posted this on the
Word bulletin board.)

3. What might other 'stuff' be that I might be able to use?

Thanks.
--
Neal Z

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Calculate string width in inches nzDec01

Dear Jim,
Thanks for the article. I knew about most of it already. In the addin I'm
developing @ workbook open I set the Options standard font to Arial size 10
in order to get a certain quantity of characters into a 'standard' cell width
in my app.

A bloke from England responding to the same question in the MS Word bulletin
board actually came up with an idea that I've turned into the steps below
that WILL work for me WELL in Excel. The key is to AUTOFIT a column width.

Dim StringArray() As String
Dim RowCount as integer

Use off screen 'unused' column as test vehicle.
Set column width property to autofit.
value .screenupdating to false

set width of column to standard width

put entire character string of words into cell
rowcount =1
redim stringarray(rowcount)

see how col width has changed

current width <= standard is good, no additional rows needed
use stringarray(rowcount) to hold first row's words. rowcount ubound
of stringarray is 1 for needed rows.

current width standard width
remove words from end of string and save in WordsToGo string
var until current col width <= standard col to get words in the row.
stringarray(rowcount) holds first row's group of words
rowcount = rowcount + 1
redim preserve stringarray(rowcount)

repeat above until WordsToGo string is null and the ubound of
stringarray is rowcount, what's needed to hold the entire string, and the
elements of stringarray are for each row's text holding cell.

Autofit the column, great idea as measuring tool.
Neal





--
Neal Z


"Jim Thomlinson" wrote:

Widths are tricky... Check out this link...

http://support.microsoft.com/default.aspx/kb/214123
--
HTH...

Jim Thomlinson


"Neal Zimm" wrote:

HI all,
The worksheets in my app must be printed on paper about 7 inches wide in a
font size of at least 18 or 20 to be read in very dim lighting. Column
widths are fixed.

If a macro generated text string does not 'fit' into the designated cells
in 1 row, I use more than 1 row to hold the text after spliting it into
'words'.

I'm trying to AVOID building a function to return the width of a character
string in inches, for a few font sizes and 1 to 3 font names.

.Shrinktofit on its own doesn't seem to help.

1. I can't find a way to test, If OneCell.Shrinktofit = true then Did
Excel actually shrink the cell contents ? This would help.

2. Is a call available to MSword that returns the width in inches of a
string, where its input is the font name and size of the characters? (It's
gotta be there, but is it available to mortals? I've also posted this on the
Word bulletin board.)

3. What might other 'stuff' be that I might be able to use?

Thanks.
--
Neal Z

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Column Width to Inches? Bob[_9_] Excel Discussion (Misc queries) 0 June 26th 11 05:14 PM
String width not exceed column width Norm Lundquist Excel Programming 6 October 17th 07 05:14 AM
How do I change column width defaults from inches to units? vateach Excel Discussion (Misc queries) 1 October 2nd 07 06:07 PM
Column width is in inches Dirk Excel Discussion (Misc queries) 0 July 1st 07 01:04 AM
Row height and Column Width to cms. or inches Ed Excel Discussion (Misc queries) 2 October 20th 06 03:01 PM


All times are GMT +1. The time now is 07:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"