Item[U] property

Microsoft Visio Developer Reference

Item[U] property

       

Returns an object from a collection. The Item property is the default property for all collections.

Version added

2.0

Syntax

objRet = object.Item(nameUIDOrIndex)

objRet

The object retrieved from the collection.

object

Required. An expression that returns a collection in the Applies to list.

nameUIDOrIndex

Required Long, String, or Variant (see Remarks for details). Contains the name, unique ID, or index of the object to retrieve.

Remarks

The data type for nameUIDOrIndex depends on the value of object.

Data type for nameUIDOrIndex

Values of object

Long

AccelItems, Acceltables, Colors, Connects, MenuItems, Menu, Menusets, Path, Paths, Selection, ToolbarItems, Toolbars, and ToolbarSets

String

Eventlist, Windows

Variant

Addons, Documents, Fonts, Hyperlinks, Layers, Masters, MasterShortcuts, OLEObjects, Pages, Shapes, and Styles

When retrieving objects from a collection, you can omit Item from the expression because it is the default property for all collections. The following statements are equivalent to the syntax example given above:

objRet = object(index)
objRet = object(stringExpression)

You can retrieve an object in a Pages, Documents, Fonts, Layers, Masters, MasterShortcuts, Styles, Shapes, Addons, or OLEObjects collection by passing the object's name as a string expression in a Variant.

If you retrieve a Shape object by name, the Item property searches all shapes in the Shapes collection's containing page or containing master, in addition to the collection's containing shape. Therefore, the Shape object returned by the Item property can be a shape that is not in the Shapes collection.

You can also pass the unique ID string of a Master or Shape object to the Item property. For example:

objRet = shpsObj.Item("{2287DC42-B167-11CE-88E9-0020AFDDD917}")

If such a string is passed to the Item property of a Shapes collection, all the shapes contained in the collection are searched. Shapes within the group shapes in the containing shape are not searched.

To search all shapes in the collection, plus the shapes inside groups and the containing shape of the collection, prefix the unique ID string with "*". For example:

objRet = shpsObj.Item("*{2287DC42-B167-11CE-88E9-0020AFDDD917}") 

Note In Visio 2000 only, shpsObj.Item("{guid}") examined the Shapes collection's containing shape and all descendants, and shpsObj.Item("*{guid}") examined all shapes in the Shapes collection's containing page or containing master.

Beginning with Visio 2000, you can refer to Visio shapes, masters, styles, pages, rows, and layers using local and universal names. When a user names a shape, for example, the user is specifying a local name. Universal names are not visible through the user interface. As a developer, you can use universal names in a program when you don't want to change a name each time a solution is localized. Use the Item property to access an object in the Masters, Pages, Shapes, Styles, Layers, or MasterShortcuts collection using its local name. Use the ItemU property to access an object from one of these collections using the object's universal name.