ShapeRange Object
| Excel Developer Reference |
Remarks
A shape range can contain as few as a single shape or as many as all the shapes on the document. You can include whichever shapes you want — chosen from among all the shapes on the document or all the shapes in the selection — to construct a shape range. For example, you could construct a ShapeRange collection that contains the first three shapes on a document, all the selected shapes on a document, or all the freeforms on a document.
Example
Returning a Set of Shapes You Specify by Name or Index Number
Use Shapes.Range(
| Visual Basic for Applications |
|---|
|
The following example sets the fill pattern for the shapes named Oval 4 and Rectangle 5 on myDocument.
Although you can use the Range property to return any number of shapes or slides, it's simpler to use the Item method if you want to return only a single member of the collection. For example, Shapes(1) is simpler than Shapes.Range(1).
| Visual Basic for Applications |
|---|
|
Returning All or Some of the Selected Shapes on a Document
Use the ShapeRange property of the Selection object to return all the shapes in the selection. The following example sets the fill foreground color for all the shapes in the selection in window one, assuming that there’s at least one shape in the selection.
| Visual Basic for Applications |
|---|
|
Use Selection.ShapeRange(
| Visual Basic for Applications |
|---|
|