Creating Text Fields to Display Information

You can insert a placeholder called a field into text that displays information such as dimensions, dates, and times. You can insert a field to show the date and time a drawing is printed, a shape’s angle of rotation, or the result of a formula you write. Visio 2007 tracks a great deal of information in the form of shape and document properties, and this information is available to you to display automatically when you insert a field. Some Visio 2007 shapes already include fields, as Figure 4-31 shows. For example, title block shapes that display file name, date, and time or a dimension line that displays shape width can do so because that data is contained in a field. Fields are automatically updated when you change a drawing.

Figure 4-31. These shapes from the Title Block stencil, located in the Visio Extras solution, include fields that display file and page properties, such as author and date, automatically.


You can add as many fields to a text block as you want. Visio 2007 includes a variety of field types, such as date and time and document information, as Table 4-8 shows. In addition, if you know the syntax for ShapeSheet formulas, you can insert a field that displays the result of your formula. See the section titled “Writing ShapeSheet Formulas” in Chapter 25.

Table 4-8. Types of Fields
Field CategoryDescription
Custom FormulaLets you enter a ShapeSheet formula in the Custom Formula box. The formula’s result is displayed in the field.
Date/TimeDisplays the date and time a file was created, revised, or printed or the current date or time
Document InfoUses information entered in the Properties box (File, Properties) to display the diagram’s creator, description, directory, file name, keywords, subject, title, manager, company, category, or hyperlink base (for linked files)
GeometryUses the shape’s width, height, and angle information to display dimensions. The Width field is useful for dimension lines. The Angle field is useful for showing how far a shape is rotated from its original position.
Object InfoUses information entered in the Special dialog box (Format, Special) to display the shape’s internal ID; master used to create it; name; type (shape, group, bit map, and so on); and values of the Data 1, Data 2, and Data 3 fields
Page InfoUses information entered in the Page Setup dialog box to display the name of the background page and the number of pages in a diagram. The Page Number field is intended for displaying a page number on a page.
Shape DataUses data entered in a shape’s custom property fields to display shape information
User-Defined CellsUses formulas entered in the Value and Prompt cells of a shape’s User-Defined Cells ShapeSheet section

When you insert a field, you can choose a format that determines how the field is displayed. Visio 2007 includes a field-formatting shorthand, which you can see in the Format area of the Field dialog box.

Among the more popular uses for fields are the following:

  • Insert page numbers in a diagram Use the Page Number field in the Page Info category.

  • Number selected shapes Use the ID field in the Object Info category. This one’s a little tricky, because you have to select all the shapes you want to number, which means that the field replaces other text in the shapes. Visio 2007 numbers the shapes according to the order you added them to the drawing page.

  • Add the date you created the diagram Use the Creation Date field in the Date/Time category.

  • Display shape dimensions on a shape Use any of the fields in the Geometry category, which is a convenient way to update technical specifications in a drawing automatically, create dimension lines, or display the measure of the rotation angle.

Inserting a Field into Text

When you insert a field in text, Visio 2007 places the field at the insertion point. Make sure to add the appropriate spacing or punctuation around the field.

Note

Remember to add appropriate labels or phrases before or after fields. For example, type Date: and then insert a date field.


To insert a field into text, follow these steps:

1.
Click the Text tool, click a shape, and then move the insertion point to where you want to insert the field.

The insertion point looks like a flashing I-beam. If you want the field to replace the text in the shape, just select the shape.

2.
Select Insert, Field to display the Field dialog box.

3.
In the Category box, select a field category.

A list of fields for that category appears in the Field box.

Note

If you select the Shape data or User-Defined Cells category and nothing appears in the Field box, the shape does not include any custom property fields or formulas in user-defined cells.

4.
In the Field section, select a field.

Format codes for the field are listed in the Format box.

5.
Click the Data Format button, and then select a format for the field information.

6.
Click OK.

Troubleshooting

If the date and time seems incorrect, double-check your field parameters. A common mistake is setting the date and/or time to the Creation Date instead of the current date.


Editing Fields

Many ready-made Visio 2007 shapes include fields that display the date or other file information. You can edit these fields to change their display format or to display different information in the field. For example, some title blocks display the date in long form, such as Monday, September 10, 2006. You can edit the field to display the date in a different format, such as Sept. 10, 2006, or 9/10/06.

To edit an existing text field, follow these steps:

1.
Click the Text tool, click a shape, and then click a field.

The field is selected. Note that you can’t place an insertion point in a field. Instead, the entire field text is highlighted.

2.
Choose Insert, Field.

The Field dialog box appears and displays the current settings for the field.

3.
To change the way the field is displayed, choose a new option under Format. Or choose a different field altogether by selecting an option in the Category and Field boxes.

4.
When you’ve edited the field, click OK.

Visio 2007 updates the shape.

Inside Out: Using custom formulas in fields

If you’re comfortable working with macro languages or have written ShapeSheet formulas, you might be interested in using the Custom Formula option to insert fields that display formula results. Typically, a custom formula includes either the FORMAT or FORMATEX function to format the formula results. The formula shorthand you use to format custom formulas is the same as that which Visio 2007 displays in the Format box of the Field dialog box. This shorthand, which Visio 2007 documentation calls a format picture, looks like a string of zeros, pound signs, and other characters and is used to specify the format for strings, numbers, currency, text, dates, and time.

For example, you can use a custom formula to display a shape’s width using any units of measure you want. If you define a field using the Width field in the Geometry category, you’re limited to displaying width in the default units of measure for the diagram. However, by creating a custom formula in a field, you can specify the units you want the result to display. If Width is in inches and you want to display it in centimeters, you would enter the following custom formula in the Fields dialog box:

= FORMATEX(Width,“0.00 u”, “in.”, “cm.”)

If a shape is 1 inch wide, this formula displays its width as 2.54 cm.

Refer to the Developer Reference Help in your Visio 2007 product for details about working with functions and format pictures.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset