During one of the Visio development cycles, the product's designers realized that the drawings could have value beyond their worth as graphical representations. Part of what makes a Visio drawing valuable is the investment of time taken to create it, but a more significant part of a drawing's value comes in the form of important, job-critical information that can be stored right in the drawing. When you view the shapes in a drawing as meaningful conveyors of information, rather than simply graphics, you can use Visio to model systems and processes. In this sense, for example, an organization chart is not just a chart, but also a visual representation of an employee database, and shapes can serve as records in that database complete with specific fields of data, such as employee name, title, date of hire, and so on. In Visio, a custom property is the means by which you associate valuable data with a shape.
You can see whether a shape has custom properties by displaying the Custom Properties window. When you select a shape on the page, the shape's properties are displayed, as Figure 6-1 shows. Some custom properties operate like fields that you type in; others are set up to provide a list of options. When you click in the latter type, an arrow appears, indicating that you can open a drop-down list of choices.
Figure 6-1. Many Visio shapes include custom properties, which you can define to store valuable information with a drawing.
Why would you want to go to all the effort of using a drawing as a data-entry form? Typing in custom property fields is bound to be time consuming. And when you look at a drawing, you don't necessarily know whether there's more data behind the shapes. The answer lies in what you can do with the data once you've entered it. Visio can automatically generate reports based on custom property data. You can display the results in a table in your drawing or save them as an external report file in HTML or XML format. Information about reports is covered later in this chapter.
In addition, you can automate the process of adding data to and extracting it from custom properties. Visio can read comma-delimited text files and a variety of databases, and custom property information can be exported. By connecting diagrams and the shapes in them to live sources of data, your drawing becomes a visual representation of your database. Companies have used Visio to set up visual network inventories, manufacturing parts databases, and other mission-critical systems where a diagram provides a recognizable and easy-to-use interface for business data.
For details about linking custom properties to existing data, see Chapter 24, "Connecting Diagrams and Databases."
Visio shapes that include built-in custom properties do so for one of two reasons:
This chapter is concerned primarily with the second use of custom properties—tracking data in diagrams. However, some shapes include both types of custom properties, as Figure 6-2 shows. In data-tracking custom properties, the initial value is usually blank, because the purpose of the property is for you to fill it in—if you want. So, for example, the outlet shape includes blank custom properties for Manufacturer, Model ID Or Tag, and Model Name. You can enter data for these fields if you want to track this type of information in an office layout or floor plan, or you can leave them blank. The shape looks the same on the page either way.
Figure 6-2. This outlet shape includes custom properties for configuring the symbol (Outlet Type) as well as optional properties for tracking data (Manufacturer, Model ID Or Tag, and Model Name).
Most shapes include at least a few custom properties for configuring that shape. A few diagram types include shapes with no custom properties at all. Other diagram types are specifically designed for tracking data, such as the organization chart shapes, and often include special commands or wizards to help you set up the data. In the chapters of this book that focus on specific diagram types, you'll find information about shapes with special custom properties.
How is it that some shapes already include custom properties? The explanation lies in how shapes inherit information from masters when you drag them from stencils onto the drawing page. You can create and save custom properties with master shapes, which is what the Visio shape designers have done, as Figure 6-3 shows. By dragging a shape on the page, you create a copy of the master shape that inherits all the master's custom properties (as well as other attributes). To use the custom properties, all you have to do is enter data.
Figure 6-3. When custom properties are defined for a master shape, every time you drag that master onto the drawing page, your shape will include the same set of properties.
Because shapes inherit properties from the master shapes, it makes sense that when you want to edit or add custom properties, you work with the master shapes. You have to decide, though, which stencil to edit:
Figure 6-4. To edit custom properties in a way that affects only the shapes in a drawing, you can edit the master shapes on the document stencil.
This is a big decision because it affects where your changes are saved—with a reusable stencil file or just in your drawing. If you don't want to affect the shapes for all future uses, you clearly don't want to edit the master shapes on the stencil. In that case, you edit the document stencil in your drawing file. The document stencil stores a copy of each master shape you've used in a drawing, as Figure 6-5 shows. By editing the master shapes on the document stencil, all the shapes in your drawing that are based on those masters will be updated. In this way, you can add, edit, and delete custom properties and affect all the shapes in your drawing.
For details about document stencils and the Visio file format, see "Mastering Visio Documents."
Figure 6-5. You can add or edit custom properties for master shapes on a Visio stencil, master shapes on a document stencil, or individual shapes in a drawing.
When you first open the Custom Properties window, Visio docks it against a ruler. However, you can place the window just about anywhere by dragging its title bar. The window can float on the drawing page and outside the Visio window, or it can dock against an edge of the page, below the drawing page in its own pane as Figure 6-6 shows, or in the stencil area. Table 6-1 lists the techniques for locating the Custom Properties window.
Table 6-1. Arranging the Custom Properties Window
Display the Custom Properties window
Choose View, Custom Properties Window.
Set the Custom Properties window to automatically move out of your way
Click the push pin icon or right-click anywhere in the Custom Properties window, and then click Turn On AutoHide.
Keep the window open at all times
Click the push pin icon or right-click in the Custom Properties window, and then choose Turn Off AutoHide.
Make the Custom Properties window float on the drawing page
Drag the window by its title bar away from its docked position, or right-click anywhere inside the Custom Properties window, and then click Float Window.
Dock the Custom Properties window
Drag the title bar of the Custom Properties window into the stencil area, against the side of the drawing page, or below the drawing page.
Figure 6-6. To prevent the Custom Properties window from obscuring your diagram while you work, you can dock the window below the drawing page.
Tip - Play a Sound When the Window Opens
You can have sounds play when the Custom Properties window opens and closes. To add sounds, open the Windows Control Panel, choose Sounds, and then define a sound for the Restore Up and Restore Down event.
You can display the custom properties temporarily for one shape by right-clicking the shape, as Figure 6-7 shows, and then selecting Properties. This won't work for all shapes. Only shapes that are designed for tracking data or for setting configuration options include the Properties command on their shortcut menus. When you display shape properties this way, Visio opens the Custom Properties dialog box, as Figure 6-8 shows. You can then enter data and click OK to close the dialog box.
Figure 6-7. When you right-click some shapes with custom properties, the Properties command appears on their shortcut menus. Not all shapes include this command.
Figure 6-8. You can work in a shape's Custom Properties dialog box instead of the Custom Properties window, but both include the same set of properties. This dialog box is for a shape from the Basic Network Shapes stencil.
Can you create custom property fields that provide configurable options, such as the built-in Visio properties that display a drop-down list of options? The answer is yes, if you're willing to write a program to do so.
It's beyond the scope of this book to describe exactly how to write such a program, but it starts with the Custom Properties section of a ShapeSheet, where you can write formulas that link a shape's geometry or style attributes to its custom properties. In that way, you can design shapes that respond to user input in the Custom Properties window. In addition, you can use an external program to create custom properties and get and set custom property values. For details, refer to the developer reference (Help, Developer Reference) or search for Visio information on http://msdn.microsoft.com.
If you want to study the way Visio shapes use custom properties, look in the ShapeSheet window. As Figure 6-9 shows, the Custom Properties section includes all the information you see in the Custom Properties window, plus a few additional options that shape programmers can take advantage of. For example, the Invisible cell lets you define a custom property that does not appear in the Custom Properties window—something you might want to do if you used an external program to control shape properties.
Figure 6-9. Cells in the Custom Properties section of the ShapeSheet show the labels and values that you see in the Custom Properties window.
You can define custom properties and their values in the ShapeSheet window, but unless you're using a program to automate the process, you're better off working with the tools in the drawing page. However, the way Visio references ShapeSheet cells affects the way certain custom property options are displayed in other parts of the user interface. For example, let's say you define a custom property called Name. Visio adds a row to the Custom Properties section of the ShapeSheet called Prop.Name. When you're creating reports or exporting data, sometimes you'll see your property listed as Name and sometimes as Prop.Name. If you're writing ShapeSheet formulas that refer to the custom property cells, you must use proper ShapeSheet syntax. For example, to refer to the value of the Name custom property in a formula, you type Prop.Name.Value where ."Value" tells Visio to look in the Value column of the Name row of the Properties section.
For details about ShapeSheet syntax, see "Writing ShapeSheet Formulas."