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

Shapes.AddChart Method (Project)

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

Creates a chart at the specified location on the active report. Returns a Shape object that represents the chart.

Syntax

expression. AddChart(Style,Type,Left,Top,Width,Height,NewLayout)

expression A variable that represents a Shapes object.

Parameters

NameRequired/OptionalData TypeDescription
StyleOptionalIntegerSpecifies the color style of the chart. The values correspond to the Change Colors drop-down list on the Chart Styles group, on the DESIGN tab, under CHART TOOLS on the ribbon (but the values are not in the same order).
TypeOptionalXlChartTypeThe type of chart to add, such as a column chart or pie chart.
LeftOptionalSingleThe position, measured in points, of the left edge of the chart.
TopOptionalSingleThe position, measured in points, of the top edge of the chart.
WidthOptionalSingleThe width of the chart, measured in points.
HeightOptionalSingleThe height of the chart, measured in points.
NewLayoutOptionalBooleanNewLayout is not used in Project.
StyleOptionalINT
TypeOptionalXLCHARTTYPE
LeftOptionalFLOAT
TopOptionalFLOAT
WidthOptionalFLOAT
HeightOptionalFLOAT
NewLayoutOptionalBOOL
NameRequired/OptionalData typeDescription

Return value

Shape

Example

The following example creates a report that has a default bar chart type with orange-colored bars.

Sub AddDefaultChart()
    Dim chartReport As Report
    Dim reportName As String

    ' Add a report.
    reportName = "Test chart report"
    Set chartReport = ActiveProject.Reports.Add(reportName)

    ' Add a chart.
    Dim chartShape As shape
    Set chartShape = ActiveProject.Reports(reportName).Shapes.AddChart(Style:=12)

    With chartShape
        .Chart.SetElement msoElementChartTitleAboveChart
        .Chart.ChartTitle.Text = "Test Chart"
    End With
End Sub

See also

Other resources

Shapes ObjectShape ObjectChart Object

© 2018 Microsoft