Range Method

See Also         Example         Applies To

Shapes object: Returns a ShapeRange object that represents a subset of the shapes in a Shapes collection.

Slides object: Returns a SlideRange object that represents a subset of the slides in a Slides collection.

Syntax

expression.Range(Index)

expression   Required. An expression that returns either a Shapes or Slides object.

Index   Optional Variant. The individual shapes or slides that are to be included in the range. Can be an integer that specifies the index number of the shape or slide, a string that specifies the name of the shape or slide, or an array that contains either integers or strings. If this argument is omitted, the Range method returns all the objects in the specified collection.

Remarks

Although you can use the Range method to return any number of shapes or slides, it's simpler to use the Item method if you only want to return a single member of the collection. For example, Shapes(1) is simpler than Shapes.Range(1), and Slides(2) is simpler than Slides.Range(2).

To specify an array of integers or strings for Index, you can use the Array function. For example, the following instruction returns two shapes specified by name.

Dim x() As Variant, myRange As Object
x = Array("Oval 4", "Rectangle 5")
Set myRange = ActivePresentation.Slides(1).Shapes.Range(x)