Windows.ItemEx property (Visio)

Returns a Window object from a collection. Read-only.

Syntax

expression. ItemEx( _CaptionOrIndex_ )

expression A variable that represents a Windows object.

Parameters

Name Required/Optional Data type Description
CaptionOrIndex Required Variant Contains the caption or index of the window to retrieve. See Remarks for details.

Return value

Window

Remarks

The ItemEx property is similar to the Item property as it applies to the Windows collection, except that the first argument can be either the window caption or the index. Beginning with Microsoft Office Visio 2003, all built-in Multiple Document Interface (MDI) windows have unique captions, although there is no guarantee that subwindows have unique captions. If there are multiple subwindows that have the same caption, ItemEx returns the one that has the lowest index.

Example

This Microsoft Visual Basic for Applications (VBA) macro shows how to use the ItemEx property to make a window active in Visio. It adds a document to the Documents collection, thereby creating a new window. Then it gets the index number of the new window (which is equal to the count of window items), uses that index number to get the new window's caption, and then passes the caption to the ItemEx property to activate the new window.

Sub ItemEx_Example() 
 
 Dim intWindowCount As Integer 
 Dim strWindowCaption As String 
 
 'Add a document not based on a template to the collection 
 Application.Documents.Add ("") 
 
 'Get the index number in the Windows collection of the new window 
 intWindowCount = Application.Windows.Count 
 
 'Get the new window's caption 
 strWindowCaption = Application.Windows(intWindowCount) 
 
 'Activate the new window 
 Application.Windows.ItemEx(strWindowCaption).Activate 
 
End Sub

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.