Design-Drawing Home  
Drawing Program
ISSN 1441-5585

Search...

Home
Articles
Software Catalog
Book Store
About
Advertising
Newsletter

 

 

Global Variables in Visio

Chris Roth

A drawing page has a ShapeSheet of it's own.Shapes can reference cells in this sheet just as they can reference cells in each other's ShapeSheets.

Some drawing page cells that are useful right off the bat. For instance, you can create a frame or border shape that automatically stretches to the size of the page by referencing page cells such as: ThePage!PageWidth and ThePage!PageHeight.

Custom Property cell GlobalVar1 added with some value in the page ShapeSheet.
Custom Property cell GlobalVar1 added with some value in the page ShapeSheet.

You can create custom "global" variables by adding Custom Properties or User cells to a drawing page’s ShapeSheet. Once you’ve created a Custom Property or User variable in the page, any shape can reference it.

This shape has its width and height set with a factor referencing the variable set in the page ShapeSheet
This shape has its width and height set with a factor referencing the variable set in the page ShapeSheet (see below). Width is set to ThePage!Prop.GlobalVar1*4 and height is set to  ThePage!Prop.GlobalVar1*8

Width is set to ThePage!Prop.GlobalVar1*4 and height is set to  ThePage!Prop.GlobalVar1*8

Once a shape references a page variable, that page variable will travel with the shape. If you drag the shape to a new page (that doesn’t have the page variable), Visio will create the page variable in the new page, so that the shape’s reference doesn’t get broken. If a shape is dropped on a page that already has a page variable, then the shape will pick up the existing value – it won’t overwrite an existent page variable with a new one. This is usually desirable behavior.

Caution: It is possible to have page variables collide, if they are named the same, but have different functions. You can imagine one solution where Prop.X=1in., and another where Prop.X="Red". If a shape expecting to reference the page and get a value like 1 in. but gets "Red" instead, the results might be somewhat unexpected.

You can use Custom Properties or User cells as page variables. With Custom Properties, a user can right-click on the page, choose Shape.Custom Properties from the shortcut menu, and change the page variables herself. If you don’t want your users mucking with page variables (perhaps you have an add-on or VBA code that changes the page variables automatically) then User cells make a better choice. A combination of the two can work well. Create user cell on the shape to reference a Custom Property on the page. Thus, the user can’t easily change the individual shape, but can make global changes by accessing the page’s properties.

Chris Roth

 

 
Rate this article...
Hmmm  OK  Good  Yes! Brilliant
Your a friend about this article.

Copyright © 1998-2007 DBM & others | Disclaimer | Privacy | Re-publication | Trademarks | Webmaster | Home