Hi Bandolier,
I'm pretty sure this involves two formulas: TEXTWIDTH and SETF.
You can see how wide the text is with a formula like this:
User.txtw = TEXTWIDTH(TheText) - LeftMargin - RightMargin
SETF gets a bit more complicated, because you can actually stuff values into other cells.
Unless I've missed an easier solution, to do what you want to do requires some looping. The ShapeSheet can handle some looping, but it wasn't really designed for it.
In words, you might do something like this:
- If the calculated text width is smaller than the shape width, use SETF to bump up the font size by 0.5pt.
- If the calculated text width is bigger than the shape width, use SETF to bump the font size down by 0.5pt.
The SETF will likely happen a few times until the font size is just right. It will be fast, so you won't see the intermediate steps.
I've tried doing this before, and it doesn't always work the way you wish it would, so something is happening in the "in between recalcs" that is hard to trace.