Shrink Wrapping a Shape to Text

hatman

Well-known Member
Joined
Apr 8, 2005
Messages
2,664
I guess I am looking more for some discussion than an answer. I am not even sure if I want to do what I am proposing, but I figured I'd see what the rest of you have to say.

I am working on an application which manipulates shapes for a block diagram.

Currently, my shape sizes are either a default minimum size, or are determined based strictly on geometry. But one of two situations concern me: 1) The shape isn't big enough to accomodate all of the text that needs to fit into it, or 2) My default minimum size is still way too big for the amount of text that is going inside of it. I am considering some method of determining an optimal size for the shape to accomdate the required text, then using the larger of that or the size required to suit geometry needs.

But what I can't figure out is how to determine what size in pixels a block of text will require. Ultimately, I would REALLY like to allow the user to globally change font size, and have each shrink-wrap itself to the new text requirements.

One option I have is to use a monotype font, where the width f every character is uniform. However, our management, in their infinite wisdom has decreed that font type for all released and controlled documents shall be Helvetica. Helvetica, as a true type font, has a variation in the width of each character, as well as a variation in the white space between characters, based on which two characters are adjacent to each other. Thiss tarts to make me dizzy just thinking about it.

Anyone have any thinghts... anyone tried doing anything like this?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I tried this with a rectangle.
Right click on the shape, and click Add Text
You do not have to put any text in it.
Then right-click on the gray pattern outside the rectangle, and click on Format Autoshape
On the Alignment tab, check the box that says Automatic size.
Click OK.

Does this work for you?
 
Upvote 0
Hah. I didn't expect that simple an answer. Of course, it won't be that simple when I finish with it. You see, I didn't make it clear, but all of my shape manipulations are ocurring through VBA. AND, all of the shapes need to retain certain relative placements. So a shape that simply changes sizes on it's own would be problematic at best. But I can cartainly paste text into asurrogate shape in a hidden sheet, then read the width and height into memory, then assign those dimensions to the shape in question, and move all of the adjacent shapes as needed to keep the placements. And if the user then edits the text, the shape won;t autosize and throw off the appearance.

MUCh simpler than I expected. Thanx Hotpepper.
 
Upvote 0

Forum statistics

Threads
1,225,229
Messages
6,183,728
Members
453,185
Latest member
radiantclassy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top