Chapter 21: Customizing Shapes and Solutions


If you think of Microsoft Office Visio 2003 as a visual toolbox rather than merely diagramming software, you’ll begin to understand how flexible it can be. If you have a business problem that requires a graphical or visual answer, Visio might be able to help. Shapes, documents, and even the Visio user interface itself can be customized. Your custom solution can be as simple as a tweak to an existing shape that you save as a new master, or a more elaborate, interactive program that uses Microsoft Visual Basic for Applications 6.4 (VBA), which is built into Visio, or another programming language. Visio is a complete graphical development environment, or platform, that you can use to build visual solutions.

This book doesn’t tell you how to program with Visio, which could easily take another thousand pages. This chapter does provide a place to start, however. With a deeper understanding of the Visio file format, you’ll know how to create your own stencils and templates, which you can distribute to other users if you want. This chapter also introduces the VBA window and points you to additional resources for taking advantage of this development environment.

Mastering Visio Documents

Behind every shape, template, and solution in Visio is a file format that makes customization possible. If you want to create your own 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:

  1. Start Visio.

  2. If Visio is already running, save any changes, and close all open Visio documents.

  3. Choose File, New, New Drawing.

    Visio opens a blank drawing page and no stencils.

  4. Choose File, Shapes, New Stencil.

    Visio opens a blank stencil, as Figure 21-1 shows.

    click to expand
    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 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:

  • Drawing (.vsd)

  • Stencil (.vss)

  • Template (.vst)

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

Visio recognizes other file name extensions as well. A Visio report definition is saved as a file with the .vrd extension, but can be read only by the Reporting tool (Tools, Report). A .vdx, .vsx, or .vtx file is a Visio drawing, stencil, or template saved in XML format. For details, see “Visio and XML File Formats,” page 616.

start sidebar
Troubleshooting
The option to open a file as an original or copy,
or as read-only, seems to be missing

In earlier 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.

end sidebar

Opening Drawing (.vsd) Files

In Microsoft Office–speak, a document is the generic term for a Microsoft Office Word 2003 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, Shapes, Show 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 any VBA projects, with their own modules, class modules, and user forms.

Opening Files That Contain Macros

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 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.

click to expand
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.

Opening Stencil (.vss) Files

The philosophy of the Visio design team has changed somewhat since Visio 2002. In earlier versions of Visio, you could edit stencils and master shapes, but not so in Visio 2003. Actually, you can edit them, but the method is just a bit different.

A Visio file with the .vss extension is sometimes referred to as a stand-alone stencil to differentiate it from a document stencil. A stand-alone stencil can be opened by itself or with a template. It cannot, however, be edited.

To open a stencil, it’s quickest to click the Shapes button on the Standard toolbar, browse through the templates, and then choose the stencil you wish to open.

Rather than edit the stencils included with Visio 2003, Visio allows you to make your own stencils composed of the shapes you most often employ in your drawings. Right-clicking a shape in any stencil displays the submenu displayed in Figure 21-3. From this menu you can save the shape to a previously constructed custom stencil (by either selecting a displayed stencil or clicking Add To Existing Stencil), save it to a new stencil (you’ll be prompted to name the stencil), or just organize your previously created shapes. You can also select File, Shapes, New to open a new, blank, editable stencil. Note that you can no longer edit most Visio stencils or the master shapes that they contain. In fact, you can only edit the masters on a Document stencil or edit anything on a custom stencil that you have created.

click to expand
Figure 21-3: You can save a shape to one of your custom stencils by right-clicking it.

After you have edited a custom stencil, you can save it by right-clicking the title bar and choosing Save (if it has already been named) or Save As, if you are saving the stencil for the first time. If you choose Save As, Visio displays the Save As dialog box, shown in Figure 21-4. The Save drop-down menu in the lower right of the Save As dialog box allows you to save the file as a Read Only or Workspace file.

click to expand
Figure 21-4: You can choose a name for your custom stencil in the Save As dialog box.

Saving and Opening Read-Only Stencils

Sometimes you cannot open a custom stencil for editing. Visio has two different ways of handling read-only custom stencils. You can drag a master onto a read-only custom 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.

click to expand
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.

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 Save to save the file as a noneditable, read-only file.

click to expand
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 by locating the file, right-clicking the file name, and then choosing Properties. In the file’s Properties dialog box, click the General tab, and then clear the Read-Only check box.

Note

Remember, in Visio 2003 only custom stencils—in other words, user-created stencils—can be edited. Stencils that ship with Visio 2003 are permanently locked.

start sidebar
Inside Out
Workspace and Read Only options

In choosing to use the common dialog boxes of Office products, the Visio designers moved some options that used to be check boxes in the Save As dialog box of previous versions of Visio. That’s why the Workspace and Read Only options are now tucked away under the Save button in the Save As dialog box.

end sidebar

Opening Template (.vst) Files

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:

  1. Choose File, Open. In the Files Of Type list, notice that All Visio Files appears, which means that you’ll see template files as well as drawing and stencil files.

  2. Locate a template (.vst) file.

    Visio installs its templates by default in the folders in C:\Program Files\Microsoft Office\Visio11\1033.

  3. Select the file name, and then click the drop-down list arrow on the Open button to display a list of options.

  4. Choose Original, and then click Open to open the original template file.

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.




Microsoft Office Visio 2003 Inside Out
Microsoft Office Visio 2003 Inside Out (Inside Out (Microsoft))
ISBN: 0735615160
EAN: 2147483647
Year: 2003
Pages: 209

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net