Controlling Shapes in Visio Using Drop Down Lists
Part five of a five-part series of blogs

Microsoft Visio lets you create far more than simple static diagrams. In this blog series we show you how to use Shape Data and the ShapeSheet to create a dynamic shape that will change its dimensions when you choose a value from a drop down list.

  1. Controlling Shape Size in Visio Using Drop Down Lists
  2. Creating Drop Down Lists in Visio Shape Data
  3. Calculating Shape Properties in the ShapeSheet
  4. Using IF Functions and Comparing Text in Visio
  5. Protecting the Contents of the ShapeSheet (this blog)

Posted by Andrew Gould on 21 June 2012

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Protecting the Contents of the ShapeSheet

We've spent a long time creating a formula that will change the size of a shape based on a drop down list, but at this point it would be very easy for our hard work to be erased.  This part of the series shows you a couple of ways to prevent that from happening.

How a ShapeSheet Formula can be Deleted

Even if your users don't know about the ShapeSheet it's remarkably easy for them to accidentally delete the formulae that you have entered.  In the example we've been creating, our formula exists in the Height property on the ShapeSheet.

Formula in ShapeSheet

You'd think your formula would be safe and sound in the ShapeSheet, but you'd be wrong!

If anybody were to change the height of the shape in the diagram, say by clicking and dragging on the resizing handles, your formula will be replaced with the new height that has been set.

Small rack size Shape transform property
Simply doing this... ...results in this.

Fortunately there are methods for preventing this!

Using Shape Protection Settings

Certain properties of a shape can be protected using a simple dialog box.  To prevent people from resizing the shape in the diagram, right-click on the shape and from the menu choose Format > Protection...

Choosing Protection

Choose this option to see which properties of your shape you can protect.


On the dialog box that appears you can check the boxes of the properties you want to protect and then click OK.

Protecting height

All that we really need to do for this shape is protect its height from being changed.


When you return to the diagram you'll find that you can't change the height of the shape by clicking and dragging on the resizing handles or by using the Size & Position window.

Protected height

The greyed out resizing handles indicate that you can't resize the shape manually, although of course you can still use your fancy drop down list.


Using the GUARD Function

An alternative method for protecting the contents of the ShapeSheet is to use the GUARD function in all of your calculations.  The syntax of this function is:

GUARD(Anything you want to protect)

Whatever you put into the GUARD function will be protected from deletion and changes made in the drawing window.  We could edit our formula so that the IF function is written inside the GUARD function - the final result would look like this:

=GUARD(IF(STRSAME(Prop.Row_1, "Small", TRUE), 2000mm, IF(STRSAME(Prop.Row_1, "Medium", TRUE), 3000mm, 4000mm)))

The effect on the shape is that you can't change its height in the drawing window:

Protected shape

Although the resizing handles aren't greyed out, you can't click and drag on them to resize the shape.


Saving a Shape on a Custom Stencil

It would be fairly pointless going through this whole process if we weren't going to make the shape available to other diagrams.  The easiest way to do this is to save the shape in a custom stencil.  I've previously written a blog on how to create custom stencils, so if you're not familiar with the technique you should probably read that article first.

Custom Stencil

Here's the empty custom stencil I've created for this demonstration.


Once the stencil has been created, all that remains is to drag the shape from the page into the stencil and it will be available for use in other diagrams.

Adding a shape to a custom stencil

Simply drag the shape from the page onto the custom stencil.


When you have the shape in the stencil you can rename it:

Renaming a shape

Right-click on the shape and choose the option shown here to rename it.


Congratulations!  You now have a re-usable, dynamic shape for building your future diagrams.

Final shape

Hopefully this will just be the starting point for the range of exciting shapes that you might create.


You can download a Visio drawing containing the dynamic rack shape that we have created here.

What's Next?

Now that you know how to control the properties of a shape using calculations in the ShapeSheet what comes next is entirely up to you!  Maybe you could calculate the colour of the rack based on its construction material (wood or metal).  You could add text to the shape that shows the total weight capacity by multiplying the number of shelves by the weight capacity of a single shelf.  And I'm sure there are many more interesting and exciting ideas you could investigate!

This blog has 0 threads Add post