Home » Development, ShapeSheet

Text Resizing with ShapeSheet Formulas

Submitted by on August 21, 2007 – 5:50 am | | 82327 views 28 Comments

« »

We see quite often in Visio’s newsgroups the question; “how do I get my font size to change with the size of my shape?” We’ll tackle that issue with some nifty ShapeSheet formulas, and a bit of philosophizing. So pull up a chair and a warm cup of coffee…




Philosophy Behind Text/Font Resizing

Okay, the question is often phrased more like; “Why the heck doesn’t Visio resize my font size when I resize my shape?!!” For the user who needs that to happen at a particular time, it seems to make perfect sense, but it’s really a philosophical issue.

If you are making a CAD drawing and have a circle with an “A” in that represents some piece of equipment, you probably want the A to get bigger or smaller along with the symbol.

But if you’re creating a flowchart, and you have a process box that needs a slightly longer description, you’d probably get angry if the font-size grew every time you stretched the shape! In this case, the box defines the limits of the paragraph, and the text inside is not symbolic or graphical.

Basic Text Resizing Formula

Okay, okay, enough theory already! What can we do to get our text to resize with our shapes?(!!!) Well, the easiest way to do this is to craft a ShapeSheet formula that compares the current height of the shape to an original height, and multiplies that by an original font size. In mathematical-formula style (ie: pseudo-ShapeSheet-code), this looks like this:

Char.Size = F0 x Height / Height0

Char.Size is the ShapeSheet cell that holds the font size for the shape. It’s located — aptly — in the Character section of the ShapeSheet. F0 is the original font size at the time of design, and Height0 is the original Height of the shape.

So if we create a shape with 12pt font, that is 0.375 in tall, the formula would look like this:

Char.Size = 12 pt * Height/0.375 in

We can see an example in action here:

Basic font-resizing Visio shape

The font-size for this shape won’t change with the Width of the shape, only the Height. So our formula won’t help us if some wise user makes the shape really thin. But this is good enough for most purposes, and we now have enough font-sizing knowledge to create more sophisticated behaviors.

Scaled Environment Formula

Warning: more theory…

Our basic formula won’t work in scaled drawings, because Visio doesn’t scale certain parts of a shape! I like to borrow concepts from AutoCAD and talk about certain ShapeSheet units being measured in “paper space” and others being measured in “drawing space”. In Visio, we might better call them “Page Units” and “Drawing Units”, but the idea is this: some quantities are better measured in their printed size (Page Units) and some are better represented in their logical, or scaled size (Drawing Units)

The size of a shape will scale, so Width & Height are in drawing units. If you switch a scale from 1:2 to 1:4, you will fit twice as many shapes on the page. A two-meter table-shape remains two-meters long, it’s just drawn smaller on the page. It’s printed size gets smaller, but its logical size stays the same.

But font-size and line weight don’t scale (imagine how frustrating that would be!), because they are measured in paper space, or Page Units. The philosophy is that we want a 12pt font to take up the same amount of paper, regardless of scale, because we want to be able to read the text. If text scaled, we might end up with lots of 0.25 pt text, or worse! And line weight usually doesn’t represent a physical attribute of an object, but simply shows it’s outline, so we don’t really want that to scale either.

So when we drop our example shape from above onto a 1:4 scaled page, the following happens:

Font problems in scaled drawings

You can see from the ruler that the shape is still 0.375 in tall, but the text is WAY too big for the shape. It is still 12 pt text and it will print at the same size it did in the 1:1 drawing, but 12 pt takes up more logical space in a 1:4 drawing.

So what went wrong? In a weird way, nothing went wrong. The font is still 12 pt, and the shape is still 0.375 in tall. So nothing really happened, but it sure looks funny! But seriously, folks…

The problem is back in our simple formula, where we are forming a ratio between Page Units and Drawing Units, without first converting one to the other. My algebra teacher would have said; “you’re comparing apples to oranges, and you can’t do that!”.

We can compare apples to apples by forming a ratio between two cells stored in every Visio Page’s ShapeSheet: PageScale and DrawingScale. These two cells get set when you choose a scale for your drawing. You can examine them by selecting nothing on a Visio page, then choosing Window > Show ShapeSheet from the menu.

The way to compare them in a shape’s ShapeSheet formula is to create a fraction that uses cross-sheet references:

User.AntiScale = ThePage!PageScale/Thepage!DrawingScale

This is sometimes called the Anti-scale formula or the Anti-scale ratio. You’ll often find it lurking in the User-defined cells section.

Our resulting, more-robust font-resizing formula will then look like this:

User.SomeFontSize = 12 pt*ThePage!PageScale/ThePage!DrawingScale*Height/0.375 in

User.SomeFontSize = 12 pt * User.AntiScale * Height/0.375 in

With this formula, our font-size will behave much more nicely in scaled drawings! Note: the 0.375 in should technically also be multiplied by an “AntiScale0” term — an originally scale ratio. But since our shape was created at 1:1, this ratio is in turn 1, so we can drop it from our formula. If the shape had been created in another scale, we’d have to add the extra fraction to get the font to size correctly.

Multiple Character Section Rows

Before this article gets two long, I’ll try and wrap it up, but not before adding a few more caveats.

The Character section is a strange beast. It can have multiple rows, but you can’t manually add them inside of the ShapeSheet! You get multiple character rows when you have multiple formatting in your shape’s text. That potentially means multiple font-resizing formulas! I’ve modified our first shape by adding some seriously frightening formatting:

Multiple Text-formatting and ShapeSheet Character Section

If you look in the Character section for this shape, you see that a whole bunch of rows have been added. Each row represents a run where the text formatting is the same. The left-most column denotes the number of characters that have the new formatting. You can see a “3” that corresponds to “Guy”, which has only been bold formatted.

You’ll also notice that our smart font-size formula has automatically been copied for us. What luck! I didn’t do that by hand, fyi. So we have nothing to worry about, right? Visio’s ShapeSheet has a read-your-mind feature that lets you fire-and-forget, right?


IF we had changed the font-size in our text, this would have changed the value in the Size cell for that character run. We would have to re-enter the formula, and probably modify it, since the font size is different. In the example, I only changed font-color, bold and italics. I never messed with the size.

If you are worried about your users messing up your font-size formulae, then think about setting the LockText and LockFormat cells in the Protection section of the ShapeSheet, or experiment with wrapping GUARD() around your Character.Size formula.

Text Margins

By default, shapes usually have non-zero values in for the text margins. These are also Page Unit values, so they don’t scale, and can throw a monkey-wrench into your font-sizing formulas.

You can examine a shape’s text margins by selecting the shape and choosing: Format > Text > Text Block tab from the menu. Or look in the ShapeSheet under the Text Block Format section, where you’ll find the LeftMargin, BottomMargin, TopMargin and RightMargin cells. Typically, these cells will have a value of 4 pt or 2 pt. As the scale of a drawing grows, those 2 or 4 points will take up more and more of your shape, as it’s printed size diminishes.

I usually opt for setting the margins to zero, wherever possible. If your text is centered, then zero-margins won’t have much of an effect anyway. Otherwise you’ll have to take them into consideration with your smart formula — and there are situations in scaled drawings when, for example, TopMargin + BottomMargin is actually greater than the height of the shape itself!


  • Ravi says:


    I have an C# application which uses visio 2003. I am facing a strange problem, I have got one page in which, if I drag and drop shapes from the stencil, the fonts get changed. This is only for a specific page. Can I know the reason.

    Thanks in Advance

  • […] ratio then serves as a multiplier for the LineWeight of each sub-shape. If you’ve read: Text Resizing with ShapeSheet Formulas then you might recognize this […]

  • Marcus says:

    I am trying to put a text box within a shape. I am trying to understand the key concepts as I build a flowchart so that I can teach other staff. Can I do this. For eg. I might have alotments in a process box and want to explain this feature with a text link that can show up as I click on it.

    Can you advise on this?

  • Visio Guy says:

    Hi Marcus,

    Visio hyperlinks are applied to the whole shape (unfortunately), so we don’t get that standard underline effect that every other piece of software seems to employ.

    That being said, you can apply more than one hyperlink to a shape, which is kind of cool.

    Hyperlinks are added to shapes in a fairly standard way: Insert > Hyperlinks… or just hit Ctrl + K

    Regardless of how many you add, you’ll see a Globe-and-chainlink icon when you mouse over a shape that has a hyperlink. To follow the link, you have to right-click and choose the link from the context menu.

    If you export the page to html, using the File > Save As Web feature, your shapes will become single-click hyperlinks, more akin to what we’re used to in browsers.

    Also, in Full Screen mode (hit F5), hyperlinked shapes follow the one-click model.

  • […] Text Resizing with ShapeSheet Formulas Customized Visio HTML Export […]

  • Chris says:

    Is there an easy solution for font resize/scaling based on the length of the string?

    e.g. If I have a rectangle shape that is 15×10, and I put STATE_VAR1 in the text box, the text will line wrap. However, resizing the text to always allow it to fit on 1 line would be nice. I haven’t found any strlen type functions that I could use to calculate a new font size/scale.


  • Graham says:


    How do I apply the “AntiScale” to the formula for shapes created in with a page scale other than 1:1? Where do I find the “AntiScale0” in the shapesheet?


  • […] If you have text on the shape that you want to edit, there are some issues with controlling font-sizes in scaled drawings that you will want to know more about. You can read all about it in: Text Resizing with ShapeSheet Formulas. […]

  • qw12 says:

    Assume that i create a Mastershape with “scalable text”, as decribed in this article.
    How can I then programmatically change all text boxes in a selection (or all on a page) to this “scalable text”?

  • […] There are lots of other factors to consider too, so luckily you can read the whole story here: Text Resizing with ShapeSheet Formulas […]

  • Bryant says:

    Great article! I have another text problem I’m hoping there is a solution to. I would like to have the text size automatically shrink from 8pt (in .5pt increments down to a limit of 6.5pt) when the amount of text in the text block is greater than the shape size. I’ve been scratching my head over this one for awhile and cannot find an answer…is this possible?

  • Visio Guy says:

    Hi Bryant,

    You can kind of do it using the ShapeSheet’s SETF(GETREF(cellname), “someformula”) functionality. But you’re really causing loops to happen when you do this, and it ends up being…kind of icky–you have the feeling that it won’t work properly every time. And it isn’t easy to get working in the first place (or explain!)

    The best method I’ve come up with is to have a hidden text box somewhere that acts as a “normalized measure”. The hidden text box contains the same text as the displayed text, but never changes font size. Therefore you can get a relative measure as to how much text there really is, and make decisions as to how much font-reduction needs to take place.

    It’s more than I can really cover here, though. So good luck messing around, or perhaps there will be an article in the future, or a utility.

    – Chris

  • Perry says:

    I am trying to create a cell (inserting a field into one) that displays the document scale. It would take me just a second to write it in myself, but would also be nice to not have to worry if I do change the scale. Can this be done?

  • Visio Guy says:

    Hi Perry,

    Look under File > Shapes > Visio Extras > Annotations.

    There are some Scale shapes that do this for you.

  • Geoff says:


    Thanks for the useful tips. This more of a question/suggestion for the guys at Microsoft: Why isn’t there an option (for example, using a check box) to “Scale text with objects”? Maybe we’ll have to wait for “Visio 2012”!

  • Visio Guy says:

    Hi Geoff,

    You are right, this probably should be an option, but I think in many, many, many Visio cases, you don’t want this to happen. Shapes act more as “paragraph boundaries”.

    Also, should the text scale only with the height of the shape, or with the width as well? What if the text is rotated at 90 degrees to the shape? It gets tricky very quickly.

    That said, it is the 21st century, and we should probably stop resorting to the ridiculous ShapeSheet sorcery explained in this article.

  • Allen says:

    In your article you mention that the original size should also be multiplied by a AntiScal0 term. Did you mean:

    User.SomeFontSize = 12 pt * User.AntiScale * Height/User.Antiscale*0.375 in ?

    if not could you clarify?


  • Visio Guy says:

    Hi Allen,

    Your formula results in User.AntiScale in both the nominator and denominator, so they would cancel out.

    Generally, font-resizing compares the current height of the shape to the original, then multiplies that by the original font size. In scaled drawings, though you have to watch out, because font sizes are not scaled, but height is (of course).

    Technically, there should probably be two anti scales: one for the original page in which the master was created, one for the target page. I think that might be what your formula was attempting.

  • Felicia says:

    Hello, Visio Guy,

    What I want to do is change the shape of the shape text box. From the suer guid you can move the associate text box but I need the text box to change size to fit the shape. I would like the text itself to wrap to a new line once it hits the set size of the text box.
    For example, I have Actor shapes form the UML stencil/template. I have created a generalization and set the name and description in the properties. However, the text just keeps getting longer and there is no limit to the size (length). This seems to be a new problem with VisioProf 2003. Because in Visio Professional 2000 I was able to manipulate the shape’s text box size just by double clicking on the shape and pulling on the text box handles.


  • jw says:

    Thanks for all your help. I just got another requirement. Limit the size of the arrow to match the size of the longest word. The logic is simple enough for a macro, but I can’t figure out how to do this from a vision shapesheet formula. Tried CALLTHIS to no great effect. Don’t see any shapesheet functions that will help me tokenize a multi-word shape text. Any ideas?

  • Nav says:

    I am using Visio 2007 and have text in a box which ‘wraps’ itself automatically, how do I unwrap it? (Changing margins has no effect.)

  • Erik says:

    Hello VG – I appreciate you putting this site together. My issue is somewhat similar to this thread, but slightly different. On a finished drawing, I need for the dimensions of different distances to actually be readable on a printed piece of paper where I don’t need a magnifying glass to read it. Even printed on large paper, these dimensions using both the horizontal and vertical dimension tool are a font like size 4. Is there a way to make these measurements larger and readable when printed?

    Thanks in advance!

  • Erik says:

    Never mind. I figured it out. Made it way too complicated. How about using the font size tool? Sorry.

  • Visio Guy says:

    🙂 Thanks for posting your solution!

  • Ruby says:

    Hi Vis,
    I’m trying to make buttons that have a single characters underlined and also change based on hover, active, enabled, or disabled. I was able to create the buttons without the underline but then the customer needs them. How do I add them. If I start over how do you underline one character?
    ps, I’m not a very seasoned developer.

  • Visio Guy says:

    Hi Ruby,

    You can get into text edit mode, often by double-clicking a shape, or you can select a shape and hit F2, or you can use the Text Tool to select a shape.

    Then, just highlight a single character in the text and press Ctrl + U to underline it.

    There is also an Underline button on the toolbar/ribbon.

  • […] There are many reasons you might want this. First, by having text “as paths”, you essentially convert characters into shapes. Shapes that resize like any other graphic. If the text on your shape is really part of the graphic, like in a STOP sign, then text as paths is a good idea, because in Visio, getting text to change font size as the shape shrinks and grows can be a bit of a chore (see: Text Resizing with ShapeSheet Formulas) […]

  • Alex says:

    Hi Visio Guy,

    I have not worked with Visio very much, so I have some questions that might be fairly obvious… I created the Section for the “User-defined Cells” and added the User.AntiScale formula as well as the User.SomeFontSize formula, but is there something else that needs to be done? For the AntiScale is “ThePage!” supposed to be the name of the page?

    Thank you,

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" extra="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.