AutoSizing Text to a Rectangle/Shape

W

Wayne Gibson

Hi,
I've been search the internet, to find a way to auto size some text so that
it fits with in the shape. I've found several references on how to resize a
shape so that the text fits.. But I want it to work the other way around.
I.E. If I create a shape which is 2" by 2", I want the text to fit within
that, reducing the font size until it does.

Any ideas?

Thanks

Gibbo
 
C

Chris Roth [MVP]

Hi Gibbo,

This is a bit more difficult. I've been working on this for awhile but my
technique isn't quite ready for Prime Time.

You could write some automation to do this, if that's an option for you.

First, create a user-cell to test the current text:

User.txtWidthTooWide = ( TextWidth(TheText) > Width )

Then, using automation code, do something like:

While shp.Cells("User.txtWidthTooWide").ResultIU = 1

'reduce the font size by one point
shp.Cells("Char.Size").ResultIU = shp.Cells("Char.Size").ResultIU - 1/72

Wend

--
Hope this helps,

Chris Roth
Visio MVP

Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/
 

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