ID property

Microsoft Visio Developer Reference

ID property

   Example   

Gets the ID of an object.

Version added

4.0

Syntax

intVal = object.ID

intVal

Long. The ID of the object.

object

Required. An expression that returns an object in the Applies to list.

Remarks

The ID of a shape is unique only within the scope of the page or master. The ID of a page, master, or style is unique within the scope of the document.

If a shape, page, master, or style is deleted, future objects in the same scope may be assigned the same ID. Therefore persisting shape or style IDs in separate data stores is generally not as sound as persisting unique IDs using the UniqueID property.

For Shape objects, you can use the ID property with methods such as GetResults and PutResults to get or set many cell values at once, possibly cells in many different shapes. To do this, you need to pass shape IDs to the methods. If you create shapes using the DropMany method, the method returns the IDs of the shapes it creates to your program.

For Font objects, the ID property corresponds to the number stored in the Font cell of the row in a shape's Character Properties section. For example, to apply the font named "Arial" to a shape's text, create a Font object representing "Arial" and get the ID of that font, then set the CharProps property of the Shape object to that ID.

The ID associated with a particular font varies from system to system or as fonts are installed and removed on a given system.

For Window objects, the ID property can be used with the ItemFromID property of a Windows collection to retrieve a Window object from a Windows collection without iterating through the collection. A Window object with a Type property of visAnchorBarBuiltIn returns an ID of visWinIDCustProp, visWinIDDrawingExplorer, visWinIDPanZoom, or visWinIDSizePos. A Window object with a Type property of visAnchorBarAddon returns an ID that is unique within its Windows collection for the lifetime of that collection. If a Window object has an ID of visInvalWinID, you cannot retrieve the Window object from its collection using the ItemFromID property.

For Event objects, the ID property uniquely identifies an Event object in its EventList collection. As long as a reference is held on an EventList collection, or on the source object of an EventList collection, you can cache the ID property of any Event object in the list. Even if other events are added to or removed from the list, the cached ID can be used later to identify the original event. If an event is persistent, its ID can be cached indefinitely. While the event with that ID might be removed, no new Event object in the same EventList collection is given the same ID.