Many Visio users discover how to insert fields into the text of Visio shapes to display data contained in Shape Data fields. But they become frustrated when they add multiple text blocks to grouped shapes, as the process becomes more tricky. Let’s take a look at how to do this!
The Insert Field Dialog
As you may or may not know, you can insert fields into shape text using the Insert Field dialog. With this technique, you can display Shape Data field values in a shape’s text, along with User-defined cells data, or any valid ShapeSheet expression.
For this article, we’ll start with the Excecutive chair shape, located on the Shapes > More Shapes > Maps and Floor Plans > Building Plan > Office Furniture stencil. The furniture shapes have been nicely updated in Visio 2016 (or Visio 2013? – I need to check), and this one’s a beauty!
To add some data to our Executive chair shape, we can follow these steps:
- Select a chair shape
- Enter text-edit mode via one of these methods:
- Press F2
- Home > Tools > Text tool
- Position the cursor before, after, within any existing text
- Open the (Insert) Field dialog via one of these methods:
- Insert > Text > Field
- Ctrl + F9
- Select Shape Data in the Category column
- Pick a field from the Field column
Below, I’ve don this twice, adding a new line between the two fields I referenced. Now our shape shows the Name and Department fields of the shape.
We can check that the references are “fo’ real” by looking at the Shape Data panel for the chair:
Multiple Text Blocks
Suppose you want to add text to different locations relative to the shape? There are many reasons why you might want to do this:
- You want to leave the default text block for user-input
- You don’t want users to blow away the inserted formulas when they type text into the shape
- Your shape follows some standard that defines explicit locations for text
- You don’t want “one big ugly” text block that lists too much data in one place
Whatever the reason, if you need more than one text block on a shape, then you need to add subshapes within a grouped shape to hold additional text. Visio shapes can only have one text block. If you have a grouped shape, then the group has only one text block, but each subshape can also display text.
Luckily, our Office chair is already a group, so we don’t have to go into the details of creating a group right now. But we’ll need to get inside the group to add a shape to contain text. To do this, try these steps:
- Open the group:
- Right-click > Group > Open Group if you’ve created the shape from scratch and it doesn’t come from a master
- Right-click > Group > Open Executive chair.19 – the underlined portion will change depending on the master your shape came from, and the indexed suffix that Visio appends to it.
- The group-editing window for the shape will open up. Note the presence of “<GROUP>” in the caption for the window. If your inside-of-Visio windows are maximized, it might look like your drawing window has disappeared, but that’s not the case. Press Ctrl + Shift + F7 to arrange the windows that are open (same command as: View > Window > Arrange All). You should now see your drawing window and group-editing window side-by-side.
- Draw a shape to contain your “sub text”. You can use Home > Tools > Text, Text Block or Rectangle tools to do this
Now you’re ready to link the text on your new subshape to data that the group carries. So you press Ctrl + F9 again, and…
Where’s the data? There are no Shape Data fields listed! What are we going to do?
The problem is that Visio is looking at the selected shape to get the offerings of fields to insert. The simple text rectangle that you’ve just drawn has precious little to offer. It’s the group that has all the juicy shape data, and after all these years, Microsoft still hasn’t updated this dialog to make it easy to access the group’s data.
Now I mentioned earlier that you can insert a field that represents any valid ShapeSheet expression, and similar to Excel, Visio’s ShapeSheet can “reach out across boundaries”, so to speak. You can get to the group, but you have to know its ID first.
- Make sure the Developer tab is turned on.
- This can be done via Customize the Ribbon…
- For details, see: How to Show the Developer Ribbon Tab (and Why)
- Make sure the group shape is selected (Make sure you’re not still in the<GROUP> editing window)
- Click the button under: Developer > Shape Design > Shape Name
- For more details, read:What’s My Shape’s ID?
- You should see the Shape Name dialog, which displays the shape’s ID:
For our example, we can see near the top of the dialog that our group’s id is 19.
Now, we can go back to where we were before. Get into the <GROUP> window, select our text subshape, enter text-edit mode, and hit Ctrl + F9. At the bottom of the Category list, we’ll need to select Custom Formula.
If we start typing in the Custom formula field below the list:
S h e e t . 1 9 ! P r o p .
We will see a list of shape data fields as soon as we hit the last dot after “prop”
Of course, your shape’s id probably won’t be 19.
A historical note: Shape Data used to be called Custom Properties in Visio. If you peek inside any ShapeSheet behind every Visio shape, the Shape Data section still displays rows that start with Prop.:
For our example, I’ll enter Custom formula = Sheet.19!Prop.SerialNumber, like so:
and voila! We’ve now got the serial number (plus a bit of additional text and styling) nicely showing text at a separate location on the chair:
…and that’s fine, as long as you only want to use the default text block of the shape. In the case of the chair, this isn’t a terrible thing, as the office furniture has a text block which is easily repositioned using a control handle.
With our new skills, we can add more fields, rearrange their positions and give them styling that makes them better blend with their parent shape:
Alternatives to Modifying Shapes
You may want to have multiple text blocks on a shape for a myriad of reasons. But if your need is to specifically display shape data, then there may be be alternatives that better suit your needs–especially if you need to view different sets of data at different times.
I suspect that a large fraction of cases might be better suited to the methods that follow.
If you have a “Professional” edition of Visio 2010, 2013, 2016 or newer, then you have the ability to apply data graphics to shapes. Data graphics are sets of adornments that can take the form of
- Data Bar
- Icon Set
- Color by Value
where each field that you want to display takes on one of the items listed above.
You can define several data graphics for a document, then choose which ones to apply. So one data graphic might show asset and serial numbers, while another data graphic would show the name and department associated with the shape. You wouldn’t need to follow all of the customization steps in this article, you just define a data graphic, apply it to a selection of shapes, then change or remove the data graphic as needed. This is great, because you don’t need to alter the structure of your shape at all!
Below, we’ve created two chairs, each containing different data. The main text has been cleared, but a custom data graphic has been applied, This data graphic shows:
- Name, Asset number and Serial number as a Text adornment
- Purchase data as an Icon Set. (Red if purchased before 2018, green if after 2018)
- Department as Color by Value
Visio also includes a legend so that color by value and icon sets are more easily understood:
Callouts – Built-in
You can also add a callout to any shape on the page via: Insert > Diagram Parts > Callout. These callouts have no automatic access to the data of the shape that they are pointing to, but now that you know about expressions like Sheet.19!Prop.SerialNumber, you can easily Ctrl + F9 insert a custom formula field into the text of the callout.
Callouts are nice in that they can be freely repositioned relative to the shape they are pointing to, but they move with their target shape. In addition, if you copy the target shape, the callout gets copied, and if you delete the target shape, the callout gets deleted. Pretty slick!
Callouts – Old, but Smarter
There are older-but-gooder callout shapes that aren’t built into Visio’s Ribbon UI. Instead are gathering dust on the venerable Callouts stencil. You can find the shapes under: Shapes > More Shapes > Visio Extras > Callouts > Custom Callout 1, 2 or 3. (If you don’t find them, it might be a limitation of the Visio Standard edition of the product. I can’t remember off the top of my head if they are included with Standard.)
In the stencil, they look like this:
The nice thing about the old callouts is that they pop up a dialog that let you choose shape data on the target shape (right-click and choose Configure Callout… if you don’t see it on drop). They also automatically insert field labels if you check the box! But unlike built-in callouts, they don’t copy nor delete with the target shape.
Here we can see an “inserted-field built-in callout”, along with an old-school callout:
However you choose to display data on your shapes, I hope it is a lot easier for you now!