Item [Documents, Shapes, Windows]

Item returns an individual item from a collection. This is the default method of Documents, Shapes, and Windows collections.

For the Documents collection, Index can be a 1-based integer or the complete path and file name of the document. The file name without the path can also be specified.

For the Shapes collection, Index can be a 1-based integer or the Object ID of the desired shape.

For the Windows collection, Index can be a 1-based integer or the name of the window as it appears in the window caption.

Syntax

object.Item( Index )

Parameter

Type

Required/

Optional

Default

Description

Index

Variant

Required

This provides the index value.

Example 1

This example demonstrates how to use a referenced document.

'Add two documents

SurferApp.Documents.Add srfDocPlot ' Create a new, blank plot document

SurferApp.Documents.Add srfDocWks ' Create a new, blank worksheet document

 

'Declares Docs as an object

Dim Docs As Object

 

'Assigns the Documents collection to the variable named "Docs"

Set Docs = SurferApp.Documents

 

'Returns a reference to the plot window (the first doc)

Set Map = Docs.Item(Index:="Plot1")

 

'Create the contour map in the referenced plot window (worksheet window visible)

Set MapFrame = Map.Shapes.AddContourMap(SurferApp.Path+"\Samples\Demogrid.grd")

 

Example 2

This example returns the second item name (shape).

'Add two shapes

 

'Declares Line as an object

Dim Line As Object

Set Line = Shapes.AddLine(xBeg:=1, yBeg:=7, xEnd:=4, yEnd:=3)

 

'Declares Ellipse as an object

Dim Ellipse As Object

Set Ellipse = Shapes.AddEllipse(Left:=5, Top:=7, Right:=6, Bottom:=10)

 

'Returns the second item (shape) name in the immediate window

Debug.Print Shapes.Item(Index:=2)

Example 3

This example demonstrates how to return the names of the windows.

'Add two documents

SurferApp.Documents.Add srfDocPlot ' Create a new, blank plot document

SurferApp.Documents.Add srfDocWks ' Create a new, blank worksheet document

 

'Declares Docs as an object

Dim Docs As Object

 

'Assigns the Windows collection to the variable named "Win"

Set Win = SurferApp.Windows

 

Debug.Print Win.Item(Index:=1)

Debug.Print Win.Item(Index:=2)

Used by: Documents collection, LegendLayers collection, Shapes collection, Windows collection