Text on Visio shapes can be
linked to dynamic information as well. Using the Field button on the
Insert tab, you can add dynamic fields to a shape’s text block.
When you click the Field button, a dialog pops up offering several categories of information that can be inserted, as shown in Table 1. The array of choices puts the field codes in the Header & Footer dialog to shame.
Table 1. Insert Field Categories for Smartening Shape Text
Field Category | Options |
---|
Shape Data | Values stored in shape data fields that might be attached to a shape |
Date/Time | Date and time information indicating when the document was created, last edited, printed, or the current date/time |
Document Info | File
and document properties information, such as creator, description,
directory, filename, keywords, subject, title, manager, company,
category |
Page Info | Name, page number, number of pages, and background page name (if any) |
Geometry | Width, height, and angle of shape |
Object Info | Developer-centric
information, such as shape ID; master name; shape name; shape type; and
information stored in legacy Data 1, Data 2, and Data 3 fields |
User-Defined Cells | Values stored in user-defined cells stored inside the shape |
Custom Formula | ShapeSheet |
Inserting Text Fields in Shape Text
1. | Start a new, blank drawing.
|
2. | Using the Rectangle tool from the Tools group on the Home tab, draw a rectangle on the page.
|
3. | With the rectangle still selected, type the text I am SO big by SO wide.
|
4. | Now replace the “SO” text with the actual width and height of the shape.
|
5. | If
you have deselected the shape, click the Text tool in the Tools group
on the Home tab, then click your shape. You can also double-click the
shape or just press F2 to get into text edit mode.
|
6. | Use the mouse to select the first “SO”. These characters will be replaced with a field.
|
7. | On the Insert tab, click the Field button in the Text group.
|
8. | Select the Geometry category from the list on the left.
|
9. | Click Width in the Field Name column on the right.
|
10. | Click
the Data Format button if you would like to change the number format.
For instance, you can show or hide the measurement units for the field
and change the number of decimals displayed.
|
11. | Click
OK until all dialogs are closed. When you stretch and shrink your
shape, the field should update with the actual width of the shape. Check
the status bar in the lower-left corner to compare the width values.
|
12. | Repeat steps 6–11, but replace the second “SO” with the height. When you resize your shape, both the width and the height should update in the shape’s text.
|
Inserted fields are indeed
powerful, and the information that you can display has much more variety
than that of headers and footers.
You can detect inserted text
fields with this simple trick: Select a shape and go into text edit mode
(I like to press F2, but you can use the Text tool on the Home tab).
Now press the left- or right-arrow key to move the text cursor along the
text. If the cursor jumps over several characters at once, you have
found an inserted field.
Of course, if the
inserted field’s value is only one character in length, this technique
doesn’t work. For decimal numbers, file paths, and dates, it is fairly
effective.
|
Using Shapes with Preconfigured Fields
The
Title Blocks stencil, located under Visio Extras in the More Shapes
menu, contains many shapes that have preconfigured text fields. You can
find shapes with preinserted information such as Date, Description,
Drawn by, Filename, File+path, Page number, Revised date/time, Drawing
scale, and Drawing title. A real timesaver indeed!
Furthermore, these shapes
have a nice feature that enables you to position the field label either
above the value or to the left. Just right-click the shape, as shown in Figure 1.
Inserted fields can be
used as shapes placed on background pages to perform functions similar
to headers and footers. Certain fields, such as page name and page
number, are smart enough to update differently for each foreground page.
Even
though there is only one shape sitting on the background page, the text
it displays is updated for each foreground page that references the
background page.