Table of contents
TOC
Collapse the table of content
Expand the table of content

Shapes.AddShape Method (Project)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

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

NameRequired/OptionalData TypeDescription
TypeRequiredMsoAutoShapeTypeSpecifies the type of AutoShape to create.
LeftRequiredSingleThe position, in points, of the left edge of the AutoShape.
TopRequiredSingleThe position, in points, of the top edge of the AutoShape.
WidthRequiredSingleThe width, in points, of the AutoShape.
HeightRequiredSingleThe height, in points, of the AutoShape.
TypeRequiredMSOAUTOSHAPETYPE
LeftRequiredFLOAT
TopRequiredFLOAT
WidthRequiredFLOAT
HeightRequiredFLOAT
NameRequired/OptionalData typeDescription

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

Other resources

Shapes ObjectShape ObjectAutoShapeType PropertyMsoAutoShapeType Enumeration (Office)

© 2018 Microsoft