Shape.UniqueID property (Visio)
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
Name | Required/Optional | Data type | Description |
---|---|---|---|
fUniqueID | Required | Integer | Gets, 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.
Constant | Value | Description |
---|---|---|
visGetGUID | 0 | Returns the unique ID string only if the shape already has a unique ID. Otherwise it returns a zero-length string (""). |
visGetOrMakeGUID | 1 | 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. |
visDeleteGUID | 2 | Deletes the unique ID of a shape and returns a zero-length string (""). |
visGetOrMakeGUIDWithUndo | 3 | Returns 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. |
visDeleteGUIDWithUndo | 4 | Clears 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}")
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기