Class Shape (Excel VBA)

The class Shape represents an object in the drawing layer, such as an AutoShape, freeform, OLE object, or picture.

The classes Comment, ConnectorFormat, FreeformBuilder, Hyperlink, PivotCache, PivotTable, Slicer and Window. give access to class Shape

Member in collection

For Each

Here is an example of processing the Shape items in a collection.

For Each s In Worksheets(1).Shapes 
    If s.HorizontalFlip Then s.Flip msoFlipHorizontal 
    If s.VerticalFlip Then s.Flip msoFlipVertical 
Next

GroupShapes.Item - Returns a single object from a collection.

Apply - expression.Apply

Copy - Copies the object to the Clipboard.

CopyPicture - Copies the selected object to the Clipboard as a picture.

Cut - Cuts the object to the Clipboard.

Delete - Deletes the object.

Duplicate - Duplicates the object and returns a reference to the new copy.

Flip - Flips the specified shape around its horizontal or vertical axis.

IncrementLeft - Moves the specified shape horizontally by the specified number of points.

IncrementRotation - Changes the rotation of the specified shape around the z-axis by the specified number of degrees. Use the Rotation property to set the absolute rotation of the shape.

IncrementTop - Moves the specified shape vertically by the specified number of points.

PickUp - Copies the formatting of the specified shape. Use the Apply method to apply the copied formatting to another shape.

RerouteConnections - This method reroutes all connectors attached to the specified shape; if the specified shape is a connector, it's rerouted.

ScaleHeight - Scales the height of the shape by a specified factor. For pictures and OLE objects, you can indicate whether you want to scale the shape relative to the original or the current size. Shapes other than pictures and OLE objects are always scaled relative to their current height.

ScaleWidth - Scales the width of the shape by a specified factor. For pictures and OLE objects, you can indicate whether you want to scale the shape relative to the original or the current size. Shapes other than pictures and OLE objects are always scaled relative to their current width.

Select - Selects the object.

SetShapesDefaultProperties - Makes the formatting of the specified shape the default formatting for the shape.

Ungroup - Ungroups any grouped shapes in the specified shape or range of shapes. Disassembles pictures and OLE objects within the specified shape or range of shapes.

ZOrder - Moves the specified shape in front of or behind other shapes in the collection (that is, changes the shape's position in the z-order).

ShapeRange.Align - Aligns the shapes in the specified range of shapes.

ShapeRange.Apply - expression.Apply

ShapeRange.Delete - Deletes the object.

ShapeRange.Distribute - Horizontally or vertically distributes the shapes in the specified range of shapes.

ShapeRange.Duplicate - Duplicates the object and returns a reference to the new copy.

ShapeRange.Flip - Flips the specified shape around its horizontal or vertical axis.

ShapeRange.Group - Groups the shapes in the specified range.

ShapeRange.IncrementLeft - Moves the specified shape horizontally by the specified number of points.

ShapeRange.IncrementRotation - Changes the rotation of the specified shape around the z-axis by the specified number of degrees. Use the Rotation property to set the absolute rotation of the shape.

ShapeRange.IncrementTop - Moves the specified shape vertically by the specified number of points.

ShapeRange.Item - Returns a single object from a collection.

ShapeRange.PickUp - Copies the formatting of the specified shape. Use the Apply method to apply the copied formatting to another shape.

ShapeRange.Regroup - Regroups the group that the specified shape range belonged to previously. Returns the regrouped shapes as a single Shape object.

ShapeRange.RerouteConnections - This method reroutes all connectors attached to the specified shape; if the specified shape is a connector, it's rerouted.

ShapeRange.ScaleHeight - Scales the height of the shape by a specified factor. For pictures and OLE objects, you can indicate whether you want to scale the shape relative to the original or the current size. Shapes other than pictures and OLE objects are always scaled relative to their current height.

ShapeRange.ScaleWidth - Scales the width of the shape by a specified factor. For pictures and OLE objects, you can indicate whether you want to scale the shape relative to the original or the current size. Shapes other than pictures and OLE objects are always scaled relative to their current width.

ShapeRange.Select - Selects the object.

ShapeRange.SetShapesDefaultProperties - Makes the formatting of the specified shape the default formatting for the shape.

ShapeRange.Ungroup - Ungroups any grouped shapes in the specified shape or range of shapes. Disassembles pictures and OLE objects within the specified shape or range of shapes.

ShapeRange.ZOrder - Moves the specified shape in front of or behind other shapes in the collection (that is, changes the shape's position in the z-order).

Shapes.Add3DModel - Creates a 3D model from an existing file. Returns a Shape object that represents the new 3D model.

Shapes.AddCallout - Creates a borderless line callout. Returns a Shape object that represents the new callout.

Shapes.AddChart2 - Adds a chart to the document. Returns a Shape object that represents a chart and adds it to the specified collection.

Shapes.AddConnector - Creates a connector. Returns a Shape object that represents the new connector. When a connector is added, it's not connected to anything. Use the BeginConnect and EndConnect methods to attach the beginning and end of a connector to other shapes in the document.

Shapes.AddCurve - Returns a Shape object that represents a Bézier curve on a worksheet.

Shapes.AddFormControl - Creates a Microsoft Excel control. Returns a Shape object that represents the new control.

Shapes.AddLabel - Creates a label. Returns a Shape object that represents the new label.

Shapes.AddLine - As it applies to the Shapes object, returns a Shape object that represents the new line on a worksheet.

Shapes.AddOLEObject - Creates an OLE object. Returns a Shape object that represents the new OLE object.

Shapes.AddPicture - Creates a picture from an existing file. Returns a Shape object that represents the new picture.

Shapes.AddPicture2 - Creates a picture from an existing file. Returns a Shape object that represents the new picture.

Shapes.AddPolyline - Creates an open polyline or a closed polygon drawing. Returns a Shape object that represents the new polyline or polygon.

Shapes.AddShape - Returns a Shape object that represents the new AutoShape on a worksheet.

Shapes.AddSmartArt - Creates a new SmartArt graphic with the specified layout.

Shapes.AddTextbox - Creates a text box. Returns a Shape object that represents the new text box.

Shapes.AddTextEffect - Creates a WordArt object. Returns a Shape object that represents the new WordArt object.

Shapes.BuildFreeform - Builds a freeform object. Returns a FreeformBuilder object that represents the freeform as it is being built.

Shapes.Item - Returns a single object from a collection.

Shapes.SelectAll - Selects all the shapes in the specified Shapes collection.

Properties

GroupShapes.Count returns a Long value that represents the number of objects in the collection.

GroupShapes.Range returns a ShapeRange object that represents a subset of the shapes in a Shapes collection.

Adjustments returns an Adjustments object that contains adjustment values for all the adjustments in the specified shape. Applies to any Shape object that represents an AutoShape, WordArt, or Connector.

AlternativeText returns or sets the descriptive (alternative) text string for a Shape object when the object is saved to a webpage.

AutoShapeType returns or sets the shape type for the specified Shape or ShapeRange object, which must represent an AutoShape other than a line, freeform drawing, or connector.

BackgroundStyle returns or sets the background style.

BlackWhiteMode returns or sets a value that indicates how the specified shape appears when the presentation is viewed in black-and-white mode.

BottomRightCell returns a Range object that represents the cell that lies under the lower-right corner of the object.

Callout returns a CalloutFormat object that contains callout formatting properties for the specified shape. Applies to a Shape object that represent line callouts.

Chart returns a Chart object that represents the chart contained in the shape.

Child returns msoTrue if the specified shape is a child shape or if all shapes in a shape range are child shapes of the same parent. Returns msoFalse if the selected shape is not a child shape. Returns msoTriStateMixed if only some of the selected shapes are child shapes.

ConnectionSiteCount returns the number of connection sites on the specified shape.

Connector true if the specified shape is a connector.

ConnectorFormat returns a ConnectorFormat object that contains connector formatting properties. Applies to a Shape object that represents connectors.

ControlFormat returns a ControlFormat object that contains Microsoft Excel control properties.

Decorative sets or returns the decorative flag for the specified object.

Fill returns a FillFormat object for a specified shape or a ChartFillFormat object for a specified chart that contains fill formatting properties for the shape or chart.

FormControlType returns the Microsoft Excel control type.

Glow returns a GlowFormat object for a specified shape that contains glow formatting properties for the shape.

GraphicStyle returns or sets an MsoGraphicStyleIndex constant that represents the style of an SVG graphic.

GroupItems returns a GroupShapes object that represents the individual shapes in the specified group. Use the Item method of the GroupShapes object to return a single shape from the group. Applies to Shape objects that represent grouped shapes.

HasChart returns whether a shape contains a chart.

HasSmartArt returns whether there is a SmartArt diagram present on the specified shape.

Height returns or sets a Single value that represents the height, in points, of the object.

HorizontalFlip true if the specified shape is flipped around the horizontal axis.

Hyperlink returns a Hyperlink object that represents the hyperlink for the shape.

ID returns a Long value that represents the type for the specified object.

Left returns or sets a Single value that represents the distance, in points, from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart).

Line returns a LineFormat object that contains line formatting properties for the specified shape. (For a line, the LineFormat object represents the line itself; for a shape with a border, the LineFormat object represents the border).

LinkFormat returns a LinkFormat object that contains linked OLE object properties.

LockAspectRatio true if the specified shape retains its original proportions when you resize it. False if you can change the height and width of the shape independently of one another when you resize it.

Locked returns or sets a Boolean value that indicates if the object is locked.

Model3D returns a Model3DFormat object that contains Model3D properties.

Name returns or sets a String value representing the name of the object.

Nodes returns a ShapeNodes collection that represents the geometric description of the specified shape.

OLEFormat returns an OLEFormat object that contains OLE object properties.

OnAction returns or sets the name of a macro that's run when the specified object is chosen.

ParentGroup returns a Shape object that represents the common parent shape of a child shape or a range of child shapes.

PictureFormat returns a PictureFormat object that contains picture formatting properties for the specified shape. Applies to a Shape object that represents pictures or OLE objects.

Placement returns or sets an XlPlacement value that represents the way the object is attached to the cells below it.

Reflection returns a ReflectionFormat object for a specified shape that contains reflection formatting properties for the shape.

Rotation returns or sets the rotation of the shape, in degrees.

Shadow returns a read-only ShadowFormat object that contains shadow formatting properties for the specified shape or shapes.

ShapeStyle returns or sets an MsoShapeStyleIndex value that represents the shape style of the shape range.

SmartArt returns an object that represents the SmartArt associated with the shape.

SoftEdge returns a SoftEdgeFormat object for a specified shape that contains soft edge formatting properties for the shape.

TextEffect returns a TextEffectFormat object that contains text-effect formatting properties for the specified shape.

TextFrame returns a TextFrame object that contains the alignment and anchoring properties for the specified shape.

TextFrame2 returns a TextFrame2 object that contains text formatting for the specified shape.

ThreeD returns a ThreeDFormat object that contains 3D-effect formatting properties for the specified shape.

Title returns or sets the title of the alternative text associated with the specified shape.

Top returns or sets a Single value that represents the distance, in points, from the top edge of the topmost shape in the shape range to the top edge of the worksheet.

TopLeftCell returns a Range object that represents the cell that lies under the upper-left corner of the specified object.

Type returns or sets an MsoShapeType value that represents the shape type.

VerticalFlip true if the specified shape is flipped around the vertical axis.

Vertices returns the coordinates of the specified freeform drawing's vertices (and control points for Bézier curves) as a series of coordinate pairs. You can use the array returned by this property as an argument to the AddCurve method or AddPolyLine method.

Visible returns or sets an MsoTriState value that determines whether the object is visible.

Width returns or sets a Single value that represents the width, in points, of the object.

ZOrderPosition returns the position of the specified shape in the z-order.

ShapeRange.Adjustments returns an Adjustments object that contains adjustment values for all the adjustments in the specified shape. Applies to any ShapeRange object that represents an AutoShape, WordArt, or Connector.

ShapeRange.AlternativeText returns or sets the descriptive (alternative) text string for a ShapeRange object when the object is saved to a webpage.

ShapeRange.AutoShapeType returns or sets the shape type for the specified Shape or ShapeRange object, which must represent an AutoShape other than a line, freeform drawing, or connector.

ShapeRange.BackgroundStyle returns or sets the background style.

ShapeRange.BlackWhiteMode returns or sets a value that indicates how the specified shape appears when the presentation is viewed in black-and-white mode.

ShapeRange.Callout returns a CalloutFormat object that contains callout formatting properties for the specified shape. Applies to ShapeRange objects that represent line callouts.

ShapeRange.Chart returns a Chart object that represents the chart contained in the shape range.

ShapeRange.Child returns msoTrue if the specified shape is a child shape or if all shapes in a shape range are child shapes of the same parent. Returns msoFalse if the selected shape is not a child shape. Returns msoTriStateMixed if only some of the selected shapes are child shapes.

ShapeRange.ConnectionSiteCount returns the number of connection sites on the specified shape.

ShapeRange.Connector true if the specified shape is a connector.

ShapeRange.ConnectorFormat returns a ConnectorFormat object that contains connector formatting properties. Applies to ShapeRange objects that represent connectors.

ShapeRange.Count returns a Long value that represents the number of objects in the collection.

ShapeRange.Decorative sets or returns the decorative flag for the specified object.

ShapeRange.Fill returns a FillFormat object for a specified shape or a ChartFillFormat object for a specified chart that contains fill formatting properties for the shape or chart.

ShapeRange.Glow returns a GlowFormat object for a specified shape range that contains glow formatting properties for the shape range.

ShapeRange.GraphicStyle returns or sets an MsoGraphicStyleIndex constant that represents the style of a shape range containing one or more SVG graphics.

ShapeRange.GroupItems returns a GroupShapes object that represents the individual shapes in the specified group. Use the Item method of the GroupShapes object to return a single shape from the group. Applies to ShapeRange objects that represent grouped shapes.

ShapeRange.HasChart returns whether a shape range contains a chart.

ShapeRange.Height returns or sets a Single value that represents the height, in points, of the object.

ShapeRange.HorizontalFlip true if the specified shape is flipped around the horizontal axis.

ShapeRange.ID returns a Long value that represents the type for the specified object.

ShapeRange.Left returns or sets a Single value that represents the distance, in points, from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart).

ShapeRange.Line returns a LineFormat object that contains line formatting properties for the specified shape. (For a line, the LineFormat object represents the line itself; for a shape with a border, the LineFormat object represents the border).

ShapeRange.LockAspectRatio true if the specified shape retains its original proportions when you resize it. False if you can change the height and width of the shape independently of one another when you resize it.

ShapeRange.Model3D returns a Model3DFormat object that contains Model3D properties.

ShapeRange.Name returns or sets a String value representing the name of the object.

ShapeRange.Nodes returns a ShapeNodes collection that represents the geometric description of the specified shape.

ShapeRange.ParentGroup returns a Shape object that represents the common parent shape of a child shape or a range of child shapes.

ShapeRange.PictureFormat returns a PictureFormat object that contains picture formatting properties for the specified shape. Applies to a ShapeRange object that represent pictures or OLE objects.

ShapeRange.Reflection returns a ReflectionFormat object for a specified shape range that contains reflection formatting properties for the shape range.

ShapeRange.Rotation returns or sets the rotation of the shape, in degrees.

ShapeRange.Shadow returns a read-only ShadowFormat object that contains shadow formatting properties for the specified shape or shapes.

ShapeRange.ShapeStyle returns or sets an MsoShapeStyleIndex value that represents the shape style of the shape range.

ShapeRange.SoftEdge returns a SoftEdgeFormat object for a specified shape range that contains soft edge formatting properties for the shape range.

ShapeRange.TextEffect returns a TextEffectFormat object that contains text-effect formatting properties for the specified shape.

ShapeRange.TextFrame returns a TextFrame object that contains the alignment and anchoring properties for the specified shape.

ShapeRange.TextFrame2 returns a TextFrame2 object that contains text formatting for the specified shape range.

ShapeRange.ThreeD returns a ThreeDFormat object that contains 3D-effect formatting properties for the specified shape.

ShapeRange.Title returns or sets the title of the alternative text associated with the specified shape range.

ShapeRange.Top returns or sets a Single value that represents the distance, in points, from the top edge of the topmost shape in the shape range to the top edge of the worksheet.

ShapeRange.Type returns an MsoShapeType value that represents the shape type.

ShapeRange.VerticalFlip true if the specified shape is flipped around the vertical axis.

ShapeRange.Vertices returns the coordinates of the specified freeform drawing's vertices (and control points for Bézier curves) as a series of coordinate pairs. You can use the array returned by this property as an argument to the AddCurve method or AddPolyLine method.

ShapeRange.Visible returns or sets an MsoTriState value that determines whether the object is visible.

ShapeRange.Width returns or sets a Single value that represents the width, in points, of the object.

ShapeRange.ZOrderPosition returns the position of the specified shape in the z-order.

Shapes.Count returns a Long value that represents the number of objects in the collection.

Shapes.Range returns a ShapeRange object that represents a subset of the shapes in a Shapes collection.

Adjustments - Contains a collection of adjustment values for the specified AutoShape, WordArt object, or connector.

CalloutFormat - Contains properties and methods that apply to line callouts.

Chart - Represents a chart in a workbook.

ConnectorFormat - Contains properties and methods that apply to connectors.

ControlFormat - Contains Microsoft Excel control properties.

FillFormat - Represents fill formatting for a shape.

GroupShapes - Represents the individual shapes within a grouped shape.

Hyperlink - Represents a hyperlink.

LineFormat - Represents line and arrowhead formatting.

LinkFormat - Contains linked OLE object properties.

Model3DFormat - Represents the properties of a 3D model shape.

OLEFormat - Contains OLE object properties.

PictureFormat - Contains properties and methods that apply to pictures and OLE objects.

Range - Represents a cell, a row, a column, a selection of cells containing one or more contiguous blocks of cells, or a 3D range.

ShadowFormat - Represents shadow formatting for a shape.

ShapeNodes - A collection of all the ShapeNode objects in the specified freeform.

ShapeRange - Represents a shape range, which is a set of shapes on a document.

TextEffectFormat - Contains properties and methods that apply to WordArt objects.

TextFrame - Represents the text frame in a Shape object. Contains the text in the text frame as well as the properties and methods that control the alignment and anchoring of the text frame.

TextFrame2 - Represents the text frame in a Shape, ShapeRange, or ChartFormat object.

ThreeDFormat - Represents a shape's three-dimensional formatting.