Previous Document Next Document
ShapeRange.Item

Property Item(IndexOrName As Variant) As Shape

Member of ShapeRange

The Item property returns the specified ShapeRange.

The Item property is the default property and its reference can be omitted when referencing items in the collection. For example, ShapeRange.Item(2) is the same as ShapeRange(2) — they both reference the second shape object in the ShapeRange collection.

The Item property returns a read-only value.

Parameters
Description
IndexOrName
Specifies the shape by its index number or name. You can use the integer number that represents the index of the shape in the range (starting from 1) or the name of the shape. If the shape with specified index or name is not in the range, a run-time error is issued.

The following code example finds the shape named MyRectangle from the selection and fills it with a uniform red fill:

Sub Test() 
 ActiveSelectionRange("MyRectangle").Fill.UniformColor.RGBAssign 
255, 0, 0 
End Sub 

The following code example fills every ellipse on the active page with a uniform blue fill:

Sub Test() 
 Dim i As Long 
 Dim sr As ShapeRange 
 Set sr = ActivePage.FindShapes(Type:=cdrEllipseShape) 
 For i = 1 To sr.Count 
  sr(i).Fill.UniformColor.RGBAssign 0, 0, 255 
 Next i 
End Sub 

The following code example performs the same procedure as the previous example. However, instead of using a For Next command, it uses the For Each command in Visual Basic to iterate through all of the shapes in the collection.

Sub Test() 
 Dim s As Shape 
 Dim sr As ShapeRange 
 Set sr = ActivePage.FindShapes(Type:=cdrEllipseShape) 
 For Each s In sr 
  s.Fill.UniformColor.RGBAssign 0, 0, 255 
 Next s 
End Sub 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.