5. Displaying Shape Data in Shape Text
Having
data behind shapes is useful if you’re interacting with Visio. But if
you need a printout or a quick overview, it’s nice to be able to see
the data at a glance.
Linking Text to Shape Data
1. | Continue working with Ch7 Shape Data.vsd.
|
2. | Select one of the light bulbs. It should have four data fields, filled with meaningful data.
|
3. | On the Insert tab, click Field.
|
4. | Select Shape Data from the Category list.
|
5. | Choose Power and then click OK. The power value is displayed in the shape’s text.
|
6. | Note that the W
is missing after the power value. This is special formatting for
displaying the value in the Shape Data window, which unfortunately
isn’t picked up when you insert text. No worries, though. You can mix
inserted fields with free-form text. Just place your cursor at the end
of the line, then enter a space and a W.
|
7. | Continue
adding fields. Select the bulb again, press F2 to enter text edit mode,
place the cursor at the end of the text, and then press Enter to start
a new line.
|
8. | Revisit the Insert Field dialog, but select the Model field this time.
|
9. | In a similar fashion, add the Bulb Type to the last line of the text.
|
10. | Verify that the shape’s text is dynamic by changing Shape Data values. The text changes to reflect the new data.
|
11. | Save your work for the next exercise.
|
Adding fields to shapes to display data is fairly
easy, doing so to lots of shapes can become tedious. Right now, your
drawing has numerous shapes with the same set of fields, but only one
has text fields linked to data.
You would think that the solution is to copy the
text from one shape and then paste to another shape. But this doesn’t
quite work. Your target shape ends up with nondynamic text that looks
correct until you realize that changing the data doesn’t change the
text any more. Luckily, there is a solution.
1. | Select a shape that has inserted fields.
|
2. | Copy the shape. Copy the whole shape; not just the text inside the shape.
|
3. | Select a target shape that has the same data fields.
|
4. | Press F2 to enter text edit mode.
|
5. | Paste.
|
Yes, you are copying a shape but pasting it into a
text block. This tells Visio to work a bit harder and hook the text to
the Shape Data. Figure 4 shows four different rectangles, with smart text displaying different data.
If you have Visio Pro or Premium, an add-on makes it
easy to configure shape text to display up to four Shape Data fields
and to change them at any time.
The Label Shapes add-on can be found by going to View, Macros, Add-ons, Maps and Floor Plans, Label Shapes.
You can apply the smart text to a selection of shapes, all shapes on the page, or all instances of a particular master. Figure 5 shows the light bulbs being modified by the Label Shapes tool.