Shapes Collection Object
Description
A collection of all the Shape objects on the specified sheet. Each Shape object represents an object in the drawing layer, such as an AutoShape, freeform, OLE object, or picture.
Note If you want to work with a subset of the shapes on a document — for example, to do something to only the AutoShapes on the document or to only the selected shapes — you must construct a ShapeRange collection that contains the shapes you want to work with.
Using the Shapes Collection
Use the Shapes property to return the Shapes collection. The following example selects all the shapes on myDocument.
Set myDocument = Worksheets(1)
myDocument.Shapes.SelectAll
Note If you want to do something (like delete or set a property) to all the shapes on a sheet at the same time, select all the shapes and then use the ShapeRange property on the selection to create a ShapeRange object that contains all the shapes on the sheet, and then apply the appropriate property or method to the ShapeRange object.
Use Shapes(index), where index is the shape's name or index number, to return a single Shape object. The following example sets the fill to a preset shade for shape one on myDocument.
Set myDocument = Worksheets(1)
myDocument.Shapes(1).Fill.PresetGradient msoGradientHorizontal, 1, msoGradientBrass
Use Shapes.Range(index), where index is the shape's name or index number or an array of shape names or index numbers, to return a ShapeRange collection that represents a subset of the Shapes collection. The following example sets the fill pattern for shapes one and three on myDocument.
Set myDocument = Worksheets(1)
myDocument.Shapes.Range(Array(1, 3)).Fill.Patterned msoPatternHorizontalBrick
Properties
Application property, Count property, Creator property, Parent property, Range property (Shapes collection).
Methods
AddCallout method, AddConnector method, AddCurve method, AddFormControl method, AddLabel method, AddLine method, AddOLEObject method, AddPicture method, AddPolyline method, AddShape method, AddTextbox method, AddTextEffect method, BuildFreeform method, Item method (Shapes collection), SelectAll method.