Controlling Shapes in Visio Using Drop Down Lists
Part three 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 (this blog)
  4. Using IF Functions and Comparing Text in Visio
  5. Protecting the Contents of the ShapeSheet

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.

Calculating Shape Properties in the ShapeSheet

So far we've created a basic rectangle shape and given it a shape data property that allows us to choose a size.  The next step is to make the shape's dimensions change based on which size we've chosen.  To do this we're going to add a calculation to the ShapeSheet.

What is the ShapeSheet?

The ShapeSheet is a miniature database or spreadsheet that contains information on almost every conceivable attribute of each shape in a diagram.  When you format a shape, or change its size, or type some text into it, all of the information is recorded in that shape's ShapeSheet.  To view the ShapeSheet, click on a shape in the diagram and from the menu select: Window > Show ShapeSheet.

The ShapeSheet

The ShapeSheet appears in a separate window and displays information about the shape that you had selected. Here we're seeing a very small part of the data stored in our basic rectangle shape.

You'll probably find it useful at this stage to maximise the ShapeSheet window to make it easier to work in.  The diagram below shows how to do this:

Maximise ShapeSheet

Click this button in the top right hand corner of the ShapeSheet to maximise it.

 

You can now switch between your drawing and the ShapeSheet using the Window menu:

Switching between windows

Click the Window menu and choose which window you want to see.

 

The Basics of Working in the ShapeSheet

In many ways the ShapeSheet in Visio behaves like an Excel spreadsheet.  You can click on a cell to select it and type in a value to change the information in that cell.  The diagram below shows how you can change the height of a shape by typing a value into the ShapeSheet:

Selecting a cell Typing a value into cell
Click on a cell to select it. Type in a value and press Enter.

You can also use the formula bar at the top of the ShapeSheet to change the value of the selected cell.  Click the green tick to enter the value when you have finished typing.

When you return to the diagram you'll see that the shape's height has changed.

Referring to Other Cells in the ShapeSheet

As well as typing a specific value into a cell, you can also refer to the value contained in another cell.  For example, we could change the Height property so that it is the same as the Width property.  To do this:

  1. Click into the Height cell and type an = sign.
Starting a formula

When you want to refer to another cell or create a calculation, start with an = sign.

 
  1. Click on the cell whose value you want to use.
Referring to another cell

When you click on another cell in the ShapeSheet it will add a reference to it in the cell that you are editing.

 
  1. Press Enter to finish creating the formula.
Final result

Visio will remove the = sign that you typed in, but you can still see it if you look in the formula bar at the top of the screen.

 

The end result of this is that you can change the width of the shape in the diagram and the height will change automatically to match it.

Dragging a shape handle Shape with changed height
Click and drag this handle to change the width of the shape. The height of the shape will change automatically.

Calculating Values in the ShapeSheet

Taking things a step further we can start to create calculations in the cells of the ShapeSheet.  We can extend the previous example so that the height of the shape is the same as the width of the shape multiplied by two.  To do this:

  1. Double-click on the Height cell to edit the formula.
Editing a formula

Double-clicking the cell allows you to edit the current value.

 
  1. At the end of the current cell contents type in an asterisk, *.
Multiplying

An asterisk is the symbol for "multiply".

 
  1. Type in the number you want to multiply by and press Enter.
Final formula

The final formula should look like this.

 

Now when you change the width of the shape in the diagram you should see that the height changes automatically to be twice the width.

Inserting Functions in ShapeSheet Calculations

Performing basic arithmetic in ShapeSheet cells is relatively simple, but to create more powerful calculations we need to be able to use functions.  Just like in Excel, a function is a name for a special type of calculation.  You can insert functions into a formula in the ShapeSheet as shown below:

  1. Click into a cell in the ShapeSheet and type an = sign.
  2. From the menu choose Insert > Function...
Inserting a function

Choose this option to see a list of the available functions.

 
  1. On the dialog box that appears, choose the function you want to insert.  The function we have selected in the diagram below is called POW and its job is to raise a number to a specified power.
Function dialog

This dialog box allows you to choose a function to insert into the formula.

 
  1. This section shows the selected function's arguments or bits of information.  This function has two arguments, one called number and the other called exponent. Check the box if you want this information inserted into the calculation for you.
  2. Click OK to insert the selected function into the formula.

At this point you should see the outline of the function inserted into the formula:

Inserted function

If you checked the box on the previous dialog box you'll see a list of the arguments that the function requires.

 

All you need to do now is replace the names of the arguments with the actual values you want to use.  So, for instance, we could make the height of the shape equal to the value of the width, raised to the power of 2.  To do this:

  1. Make sure that you are editing the cell and select the name of the argument you want to replace.
Selecting argument name

You can use the mouse to select the argument name by clicking and dragging, or by simply double-clicking on it.

 
  1. Either type in the new value you want to use, or click on the ShapeSheet cell to which you want to refer.  Here we're using the Width cell as the number.
Replacing argument

Clicking on another cell will replace the argument name with a reference to the cell on which you have clicked.

 
  1. Repeat this process with each of the other arguments until you have replaced them all and then press Enter.
The completed function

This is what the function should look like when you've finished.

 

You can see a list of all of the available functions in Visio, along with a description of what they do, here.

What's Next?

Now you know about the ShapeSheet and how to create calculations and insert functions we can get back to the task at hand: how to change the size of a shape based on the value selected in a drop down list.  Read the next part of this series to see the combination of functions that we need to use.

This blog has 0 threads Add post