Table of contents
TOC
Collapse the table of content
Expand the table of content

Shape.UniqueID Property (Visio)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Gets, deletes, or makes the GUID that uniquely identifies the shape within the scope of the application. Read-only.

Syntax

expression . UniqueID( fUniqueID )

expression An expression that returns a Shape object.

Parameters

NameRequired/OptionalData TypeDescription
fUniqueIDRequiredIntegerGets, deletes, or makes the unique ID of a Shape object. See Remarks for possible values.

Return Value

String

Remarks

Microsoft Visio identifies shapes by two different IDs: shape IDs and unique IDs. Shape IDs are numeric and uniquely identify shapes within the scope of an individual drawing page. They are not unique within a wider scope, however.

Unique IDs are GUIDs. They are unique within the scope of the application.

To convert between shape IDs and unique IDs, you can use two methods of the Page object, ShapeIDsToUniqueIDs and UniqueIDsToShapeIDs .

By default, a shape does not have a unique ID. A shape acquires a unique ID only if you set its UniqueID property.

If a Shape object has a unique ID, no other shape in any other document will have the same ID.

The fUniqueID parameter controls the behavior of the UniqueID property. It should have one of the following values declared in the Visio type library in VisUniqueIDArgs .

ConstantValueDescription
visGetGUID0Returns the unique ID string only if the shape already has a unique ID. Otherwise it returns a zero-length string ("").
visGetOrMakeGUID1Returns the unique ID string of the shape. If the shape does not yet have a unique ID, it assigns one to the shape and returns the new ID.
visDeleteGUID2Deletes the unique ID of a shape and returns a zero-length string ("").
visGetOrMakeGUIDWithUndo3Returns the unique ID string of the shape. If the shape does not already have a unique ID, assigns one to the shape and returns the new ID. Undoable.
visDeleteGUIDWithUndo4Clears the unique ID of a shape and returns a zero-length string (""). Undoable.

To get a shape if you know its unique ID, use Shapes.Item ( UniqueIDString).

For example, you can use the following code:

Dim vsoShape As Visio.Shape 
Set vsoShape = Visio.ActivePage.Shapes.Item("{2287DC42-B167-11CE-88E9-0020AFDDD917}") 

Alternatively, you can use the following code, which adds the letter "U" before the string to identify it as a unique ID:

Dim vsoShape As Visio.Shape 
Set vsoShape = Visio.ActivePage.Shapes.Item("U{2287DC42-B167-11CE-88E9-0020AFDDD917}") 
© 2017 Microsoft