Hi Stefan,
You *can* get this to happen, but I'm not sure how kosher it is. You can
actually get the ShapeSheet to loop to some extent, or "ratchet" perhaps is
a better term.
Try inserting a user-cell, say User.textWatch, and set the formula as so:
User.textWatch =
=IF(TEXTWIDTH(TheText)>Width,SETF(GetRef(Char.Size),Char.Size*0.9),0)
The formula uses the TEXTWIDTH function to measure the text.
If the text is not wider than the shape, then nothing happens -- the "0".
If the text is wider than the shape, then SETF jams a new value into the
font-size cell: Char.Size. The expression sets the value of Char.Size to 90%
of itself. You can imagine that this might happen a number of times - a
loop! But we don't really see the loop happening.
The performance seems OK. I believe the the ShapeSheet designers put some
safeguards in to prevent infinite loops, so you probably won't break
anything. But this is a bit of a stretch for a spreadsheet engine : )
Note, this won't make your text automatically bigger. But the user can
simply choose a larger font size. If it's too big, then Char.Size will get
ratcheted down until it fits.
Note also that we are only setting Char.Size. If you have multiple
formatting in the shape's text (bold, italic, etc) then you'll have multiple
Character rows. I.e. setting Char.Size won't be enough because there will be
multiple cells that need setting. At this point, you're getting beyond what
the ShapeSheet can handle on it's own, and need code to track all the rows.
Last note: to make sure that the font size doesn't go negative or get too
small, the formula should have some bounds. Here's an example of a
lower-bound:
=IF(TEXTWIDTH(TheText)>Width,SETF(GetRef(Char.Size),MAX(1
pt,Char.Size*0.9)),0)
--
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/