Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Sizing Autoshapes based on text length

The automatic sizing feature in Autoshape formatting seems buggy to me.
I'm using Excel XP, and when I auto size, it resizes the shape so that
all the text is on one line.

I would like to keep the width of the shape the same, but adjust the
height based on the length of the text. Anyone got any ideas on how I
can do this in VBA?

Thanks,
Nick

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Sizing Autoshapes based on text length

BTW, a good example of what I'm talking about can be seen in Word. When
you doing automatic sizing in Word with the wrap text option selected,
the shape width remains the same but the height adjusts to fit.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Sizing Autoshapes based on text length

Hi Nick,

Couple of ways -

Put text into a cell in an empty row and set column to pre determined width.
Wrap text. Autofit the column and return it's height.

A textbox will autosize to height if the text has line breaks. This would
entail guestimating max characters that would fit into your pre-determined
width, finding the first space to the left of the end and replacing with a
linefeed, not chr(13) or vbCr, but a single vbLf or chr(10).
Also pad one line with characters that will autosize to correct width (to be
removed later). Cater for margins.

Once autosize'd, if you want to replace text without the line feeds, remove
the Autosize setting having got the new dimensions to re-dimension if
necessary.

I find textbox autosize more accurate than sheet column autosize. The latter
approximates according to the default font width and the small cell indent
is slightly version dependant. However the cell method is much simpler,
although there is a max string length limit.

Not sure I've explained all that very well!

Regards,
Peter T

PS Maybe a third way might be to do it in a hidden instance of Word the way
you say - never tried.



"Nick Hebb" wrote in message
oups.com...
BTW, a good example of what I'm talking about can be seen in Word. When
you doing automatic sizing in Word with the wrap text option selected,
the shape width remains the same but the height adjusts to fit.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Sizing Autoshapes based on text length

Typo

Autofit the column and return it's height.


should read of course

Autofit the row (entirerow) and return it's height.

Peter T

"Peter T" <peter_t@discussions wrote in message
...
Hi Nick,

Couple of ways -

Put text into a cell in an empty row and set column to pre determined

width.
Wrap text. Autofit the column and return it's height.

A textbox will autosize to height if the text has line breaks. This would
entail guestimating max characters that would fit into your pre-determined
width, finding the first space to the left of the end and replacing with a
linefeed, not chr(13) or vbCr, but a single vbLf or chr(10).
Also pad one line with characters that will autosize to correct width (to

be
removed later). Cater for margins.

Once autosize'd, if you want to replace text without the line feeds,

remove
the Autosize setting having got the new dimensions to re-dimension if
necessary.

I find textbox autosize more accurate than sheet column autosize. The

latter
approximates according to the default font width and the small cell indent
is slightly version dependant. However the cell method is much simpler,
although there is a max string length limit.

Not sure I've explained all that very well!

Regards,
Peter T

PS Maybe a third way might be to do it in a hidden instance of Word the

way
you say - never tried.



"Nick Hebb" wrote in message
oups.com...
BTW, a good example of what I'm talking about can be seen in Word. When
you doing automatic sizing in Word with the wrap text option selected,
the shape width remains the same but the height adjusts to fit.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Sizing Autoshapes based on text length

Not sure I've explained all that very well!

Explanations were perfectly clear.

Unfortunately, nothing is really working well for the non-rectangular
autoshapes like flowchart decision shapes (diamonds). It would be a lot
easier if I could get a handle for the textframe object and determine
it's width. But for now I've had to do mockups for each shape based on
the standard font and make adjustments for different fonts and sizes.
It's gotten fairly convoluted.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Sizing Autoshapes based on text length

OK I follow your objective. Doable but rather you than me!

Regards,
Peter T

"Nick Hebb" wrote in message
ups.com...
Not sure I've explained all that very well!


Explanations were perfectly clear.

Unfortunately, nothing is really working well for the non-rectangular
autoshapes like flowchart decision shapes (diamonds). It would be a lot
easier if I could get a handle for the textframe object and determine
it's width. But for now I've had to do mockups for each shape based on
the standard font and make adjustments for different fonts and sizes.
It's gotten fairly convoluted.



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
Summing a column based on the length of text in a cell in anothercolumn [email protected] Excel Worksheet Functions 13 November 26th 08 05:42 PM
How to remove text edit from Autoshapes SupperDuck Excel Discussion (Misc queries) 4 November 19th 08 05:01 PM
How can I export text from excel autoshapes to a text file? Donncha Excel Discussion (Misc queries) 0 July 20th 06 04:58 PM
How do I "conditionally" change font size based on text length? Found in Florida Excel Programming 2 October 10th 05 11:12 PM
How do you find and replace text in autoshapes or comments the_lipster Excel Discussion (Misc queries) 0 June 17th 05 12:35 AM


All times are GMT +1. The time now is 11:47 AM.

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

About Us

"It's about Microsoft Excel"