Microsoft Visio Version 2002 Inside Out (Inside Out (Microsoft))
3 4
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 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 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 Forms Shapes stencil 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 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.
Table 4-8. Types of Fields
Field Category | Description |
---|---|
Custom Formula | Lets you enter a ShapeSheet formula in the Custom Formula box. The formula's result is displayed in the field. |
Date/Time | Uses information from the Windows Control Panel to display the date and time a file was created, revised, or printed or to display the current date or time. |
Document Info | Uses 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). |
Geometry | Uses 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 Info | Uses 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 Info | Uses 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. |
Custom Properties | Uses data entered in a shape's custom property fields to display shape information. |
User-Defined Cells | Uses 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 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 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 places the field at the insertion point. Make sure to add the appropriate spacing or punctuation around the field.
Tip
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:
- 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.
- Select Insert, Field to display the Field dialog box.
- 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 Custom Properties 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. - In the Field section, select a field.
Format codes for the field are listed in the Format box.
- In the Format box, select a format for the field information.
For example, if you select the Current Date field and select Long Date, the date appears as Thursday, November 15, 2001. If you select dd/MM/yy, the date appears as 15/11/01.
- Click OK.
Editing Fields
Many ready-made Visio 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, 2001. You can edit the field to display the date in a different format, such as Sept 10, 2001, or 11/27/00.
To edit an existing text field, follow these steps:
- 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.
- Choose Insert, Field.
The Field dialog box appears and displays the current settings for the field.
- 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.
- When you've edited the field, click OK.
Visio updates the shape.
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 displays in the Format box of the Field dialog box. This shorthand, which Visio 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.
For an introduction to formulas in Visio, see "Writing ShapeSheet Formulas." Also refer to the Developer Reference Help in your Visio product for details about working with functions and format pictures.