Share via


UniqueID Property [Visio 2003 SDK Documentation]

As it applies to the Master object.

Returns the unique ID of a master.

strRet = object**.UniqueID**

strRet     String. The unique ID of the Master object.

object     Required. An expression that returns a Master object.

Version added

4.0

Remarks

A Master object always has a unique ID. If you copy a master, the new master has the same unique ID as the original master (as well as the same base ID). However, if you change the new master, a new unique ID is assigned but the base ID remains the same.

For details about the base ID, see the BaseID property.

You can determine a Master object's unique ID by using the following code:

strID = vsoMaster.UniqueID

The value it returns is a string in the following form:

{2287DC42-B167-11CE-88E9-0020AFDDD917}

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

For example, you can use the following code to retrieve the master from the Masters collection of the active document:

Dim vsoMaster As Visio.Master
Set vsoMaster = Visio.ActiveDocument.Masters("{0478DA94-1315-9876-8E4C-006523ABC9B2}")

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 vsoMaster = Visio.ActiveDocument.Masters("U{0478DA94-1315-9876-8E4C-006523ABC9B2}")

As it applies to the Shape object.

Returns or clears the unique ID of a shape.

strRet = object**.UniqueID**(fUniqueID)**

strRet     String. The unique ID of the Shape object.

object     Required. An expression that returns a Shape object.

fUniqueID     Required Integer. Gets, assigns, or clears the unique ID of a Shape object.

Version added

4.0

Remarks

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 argument controls the behavior of the UniqueID property. It should have one of the following values declared in the Visio type library in VisUniqueIDArgs.

Constant Value

visGetGUID

0

visGetOrMakeGUID

1

visDeleteGUID

2

The constant visGetGUID returns the unique ID string only if the shape already has a unique ID. Otherwise it returns a zero-length string ("").

The constant visGetOrMakeGUID returns 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.

The constant visDeleteGUID clears the unique ID of a shape and returns a zero-length string ("").

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}")

Applies to | Master object | Shape object

See Also | BaseID property | Item property | Shapes collection