Previous Document Next Document

Object Model Reference : Classes : S : ShapeRange : Properties : ShapeRange.Item


ShapeRange.Item

Property Item(IndexOrName As Variant) As Shape

Description

Member of ShapeRange

The Item property returns a specified shape in a shape range. It is the default property of the ShapeRange class.

The Item property returns a read-only value.

Parameter
Description
IndexOrName
Specifies the index number or name of the shape in the shape range:
 
Index — Specifies the preset placeholder that uniquely identifies each shape in the shape range
 
Name — Specifies the string that uniquely identifies each shape in the shape range

VBA example 1

The following VBA 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
VBA example 2

The following VBA 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
VBA example 3

The following VBA 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 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 2013 Corel Corporation. All rights reserved.