Shapes.AddShape method (Project)

Adds a shape of the specified AutoShape type to a report, and returns a Shape object that represents the new shape.

Syntax

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

expression A variable that represents a Shapes object.

Parameters

Name Required/Optional Data type Description
Type Required MsoAutoShapeType Specifies the type of AutoShape to create.
Left Required Single The position, in points, of the left edge of the AutoShape.
Top Required Single The position, in points, of the top edge of the AutoShape.
Width Required Single The width, in points, of the AutoShape.
Height Required Single The height, in points, of the AutoShape.
Type Required MSOAUTOSHAPETYPE
Left Required FLOAT
Top Required FLOAT
Width Required FLOAT
Height Required FLOAT
Name Required/Optional Data type Description

Return value

Shape

Remarks

To change the type of an AutoShape, set the AutoShapeType property.

Example

The following example creates a report that contains two cloud shapes, and then changes the second cloud shape to a yellow speech balloon.

Sub TestShapes()
    Dim shapeReport As Report
    Dim reportName As String
    
    ' Add a report.
    reportName = "Shape report"
    Set shapeReport = ActiveProject.Reports.Add(reportName)

    ' Add two clouds.
    Dim cloudShape1 As shape
    Dim cloudShape2 As shape
    Set cloudShape1 = shapeReport.Shapes.AddShape(msoShapeCloud, 20, 20, 100, 60)
    Set cloudShape2 = shapeReport.Shapes.AddShape(msoShapeCloud, 100, 200, 60, 100)
    
    ' Change the blue cloud to a yellow speech balloon.
    cloudShape2.AutoShapeType = msoShapeBalloon
    cloudShape2.Fill.ForeColor.RGB = &H80FFFF
End Sub

See also

Shapes Object Shape Object AutoShapeType Property MsoAutoShapeType enumeration (Office)

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.