Dev Luv: Identify Visio Shapes By ID, Not Name


The name of a Visio shape is not unique on a page. The name is only unique in its container. Visio developers often try to identify shapes or types of shapes using the Shape.Name property. This can cause problems for two reasons: users can modify the shape’s Name property using the Format | Special dialog and shape names are not unique on a page. Instead, use the Shape.UniqueID property to identify shapes in a document. You can also use Shape.ID or Shape.NameID to identify a shape within a page. Internally, Visio has a quick mechanism of accessing shapes by GUID so the performance is good.

 

Shape type identification is best done using user cells. Shape type identification by user cells gives developers the ability to identify categories of shapes in a given document. The Visio solutions store shape type IDs in user cells. For example, Visio’s Organization Chart solution stores these values in a user cell called User.ShapeType. “1” represents an executive, “2” represents a manager, and “3” represents a position. When you change the value in the User.ShapeType cell either programmatically or manually through the ShapeSheet, it changes the type of shape. This is a handy technique if you need to change a shape type and don't want to deal with the "drop shape, reconnect shape to other shapes" sequence of steps.  

 

Happy Thanksgiving, everyone!

 

-- Mai-lan

 

This posting is provided "AS IS" with no warranties, and confers no rights