3 4
Behind every shape, template, and solution in Visio is a file format that makes customization possible. If you want to create your own masters and stencils, or customize templates for others or just yourself, you need to understand this fundamental fact of Visio life: All Visio files have the same format, and that format includes a drawing page and a stencil. That is, every drawing page has a stencil, and every stencil has a drawing page. The file name extension determines what you see when you open a file, which is why when you open a stencil (.vss) file, you typically don't see the drawing page, or when you open a blank drawing (.vsd) file, you don't see a stencil.
Here's a little experiment you can try to see how this works:
Visio opens a blank drawing page and no stencils.
Visio opens a blank stencil, as Figure 21-1 shows.
Figure 21-1. A Visio file includes a drawing page and a document stencil. The file name extension determines whether Visio opens both a drawing page window and a stencil window.
Why is this important? The fact that a Visio file has both a drawing page and a stencil has all kinds of ramifications that can help you work with shapes more efficiently and keep file size down when you customize stencils and templates. Visio uses the document stencil to store copies of any masters added to that drawing file. Shapes on the drawing page are instances of the masters on the document stencil. One convenient side effect of the relationship between shapes on the page and masters on the document stencil is that you can edit masters on a document stencil, and the change will affect all the copies of the master in that drawing file.
If a Visio file always contains a drawing page and a stencil, why are there different types of files? You can open and save Visio files with the following file name extensions:
The Visio engine uses the file name extension to determine what to display on the screen when the document is opened—that is, which windows should be active. You can save a Visio file using any other Visio file name extension to change what appears when the file is opened. For example, you can save a drawing file (.vsd) as a template (.vst), which you can then open and work with as a template. The sections that follow describe what happens when you open each file type.
Note
The option to open a file as an original or copy, or as read-only, seems to be missing.
In previous versions of Visio, the Open dialog box included check boxes for opening a file as an original, copy, or read-only version. Those options still exist; they're just harder to find. In the Open dialog box, click the drop-down arrow on the Open button to display a menu. Choose the option you want, and then click the Open button again to open the selected file as specified.
In Microsoft Office–speak, a "document" is the generic term for a Word file or the thing you create when you press Ctrl+N. The equivalent generic term in Visio is drawing file, which has the .vsd file name extension. When you click the New button on the Standard toolbar, or press Ctrl+N in Visio, you create a drawing file. When you open an existing drawing file, Visio opens all the windows and files that were open when the file was last saved. Visio maintains an internal workspace list that saves this information. Typically, a drawing file displays only the drawing page window; its document stencil window is closed. To display the document stencil, choose File, Stencils, Document Stencil.
Each Visio drawing file always has at least one drawing page, a document stencil, and a workspace list. A drawing file's document stencil contains copies of any masters used on the drawing page. In addition, a drawing file always includes the five default Visio styles (Guide, No Style, None, Normal, and Text Only), a color palette, a default VBA project with an empty class module called ThisDocument, and a document sheet (that is, a ShapeSheet for the document) that can store user-defined data.
That is the minimum list of contents for a drawing file. You can customize the file's color palette and style lists, and those changes will be saved with the file, as will be any VBA projects, with their own modules, class modules, and user forms.
InsideOut
Although this book doesn't delve much into VBA, be aware that VBA projects are part of a drawing file. When you open a drawing file that includes VBA or other project code, as some of the sample files do, you'll see the message shown in Figure 21-2. This message is a new safeguard feature of Visio. Despite the dire tone of the message, you probably want to click Enable Macros if you know the source of the drawing file. The macros are most likely used to provide functionality within the drawing, such as adding a control, menu, or special command.
Figure 21-2. When you open a drawing file that includes a VBA macro or other programming code, Visio displays this message to warn you about its contents. Usually the macros are needed to enable interactive features of the drawing.
You can prevent this message by lowering the security settings for Visio, which generally is not a good idea unless you have virus-scanning software installed on your computer. To do this, choose Tools, Macros, Security. On the Security Level tab of the Security dialog box, click the Low option, and then click OK.
A Visio file with the .vss extension is sometimes referred to as a standalone stencil to differentiate it from a document stencil. A standalone stencil can be opened by itself or with a template. When you open a stencil file, Visio's default behavior is to open it as read-only in a docked window, if a drawing window is active. If a drawing window is not active—that is, you're opening the stencil by itself—the Visio engine creates a stencil window and displays the file's stencil. The stencil's drawing page is closed, but you can display it by choosing Window, Show Drawing Page.
To open a standalone stencil file so that you can edit it, you need to specify whether you want to open the original or a copy of the stencil, as Figure 21-3 shows. To open a stencil for editing, it's quickest to choose File, Stencils, Open Stencil, because Visio then displays the stencil folders (or the stencil path you've specified on the File Paths tab of the Options dialog box).
Note
An original or copy of a stencil file is displayed in a stencil window as opposed to a dockable stencil pane. When a stencil window is active (you make a window active by clicking its title bar), Visio adds the Master menu, which contains commands for editing masters and master icons. The reason a stencil file needs a drawing page is that the page stores the drawing scale, styles, and other settings used in the document. You can add or edit the masters on a standalone stencil, which is an efficient way to edit a shape you use frequently. When you next open a Visio drawing or template file that includes the stencil, you can use the revised master.
Figure 21-3. When you open a stencil, Visio opens it as read-only unless you specify otherwise in the Open Stencil dialog box.
Tip
If you're working in a drawing that includes docked standalone stencils, and you want to open one for editing, you can right-click its title bar, and then choose Edit. When a docked stencil is open for editing, its title bar displays a red asterisk, as Figure 21-4 shows. You won't see the Master menu, but you can access the same commands by right-clicking a green area in the stencil.
Note
Figure 21-4. To open a stencil for editing, open it as an original file or right-click the stencil title bar, and then choose Edit.
Sometimes you cannot open a stencil for editing. Visio has two different ways of handling read-only stencils. Most of the time, Visio opens a stencil as a read-only file, but gives you the option to open it for editing. For example, you can drag a master onto a read-only stencil, and Visio prompts you to open the stencil for editing. This is the default Visio behavior for read-only stencils. However, stencils can be saved in such a way that they cannot be opened for editing. This type of read-only protection disables the editing option and displays a message if you try to open the stencil for editing, as Figure 21-5 shows.
Figure 21-5. If a message like this appears when you try to open a stencil for editing, the stencil file has been saved as a read-only file. The original file cannot be edited unless you reset the Read-Only flag in Windows.
Visio uses the Windows Read-Only flag to specify that the original stencil file cannot be edited. To set this flag, use the regular Save or Save As command on the File menu to save a stencil, but click the drop-down list arrow on the Save button in the dialog box, as Figure 21-6 shows. You'll see two options: Workspace and Read Only. Select Read Only, and then click the Save button to save the file as a non-editable read-only file.
Figure 21-6. If you specify Read Only when you save a stencil file, the original stencil cannot be opened for editing until you clear the Read Only flag in Windows.
Once a file is flagged as read-only in this way, you can't edit the original file until you reset the Read Only flag. You can do this in Windows Explorer: Locate the file, right-click the file name, and then choose Properties. In the file's Properties dialog box, click the General tab, and then clear the Read-Only check box.
InsideOut
Many users are never even aware that they're opening a template when they start Visio and choose a drawing type. Despite the fact that templates have been a cornerstone of Visio functionality since the very first release, the word template seems to confuse people. Nonetheless, when you choose a drawing type on Visio's initial launch screen, you're really opening a template (.vst) file.
When you open a template, Visio's default behavior is to open an untitled copy of the template as a drawing file (.vsd) and open any other windows and files listed in the template's workspace. Just because most Visio templates have a blank drawing page doesn't mean that a template has to have a blank drawing page. For example, you can open a drawing, add a border and title block, and then save it as a template (.vst) file that can be opened to generate other drawings. A template can include more than one drawing page as well, although Visio's templates typically include only one page for ease of use. You can open an original template file to make changes to the template itself, such as adding stencils or setting default styles.
Follow these steps to open the original template file instead of the copy that Visio typically opens:
Visio installs its templates by default in the folders in C:\Program Files\Microsoft Office\Visio10\1033\Solutions.
The tricky thing with templates is that you're usually opening at least two separate documents, and often more than two. Most templates include a Visio drawing file. That's the drawing page you see when you open the template. In addition, most templates include one or more stencil files. When you open a .vst file, Visio knows to open the drawing file's drawing page in a drawing window and the stencil file's document stencil in the stencil window. When you recall that both drawing and stencil files contain both a drawing page and a document stencil, you'll see that this makes sense.
Templates also include a workspace list with information about the size and position of each open window, as well as the style definitions and colors that are available to users when they create diagrams. The drawing can have its own style definitions and color palette, as can the stencils, so if you're creating new templates, it's important to make sure that style and page settings work together across documents.