AddShape Method

Applies To

Shapes collection object.

Description

Creates an AutoShape. Returns a Shape object that represents the new AutoShape.

Syntax

expression.AddShape(Type, Left, Top, Width, Height)

expression Required. An expression that returns a Shapes object.

Type Required Long. Specifies the type of AutoShape to create. Can be any one of the MsoAutoShapeType constants.

Left, Top Required Single. The position (in points) of the upper-left corner of the AutoShape's bounding box relative to the upper-left corner of the document.

Width, Height Required Single. The width and height of the AutoShape's bounding box, in points.

Remarks

To change the type of an AutoShape that you've added, set the AutoShapeType property.

Example

This example adds a rectangle to myDocument.

Set myDocument = Worksheets(1)
myDocument.Shapes.AddShape msoShapeRectangle, 50, 50, 100, 200