title | ms.service | ms.assetid | ms.date | ms.localizationpriority |
---|---|---|---|---|
Shapes.AddChart method (Project) |
project-server |
d404a9de-c1aa-c2a0-bf85-dc1f1735cf3c |
06/08/2017 |
medium |
Creates a chart at the specified location on the active report. Returns a Shape object that represents the chart.
expression. AddChart
(Style, Type, Left, Top, Width, Height, NewLayout)
expression A variable that represents a Shapes object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
Style | Optional | Integer | Specifies 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). |
Type | Optional | xlChartType | The type of chart to add, such as a column chart or pie chart. |
Left | Optional | Single | The position, measured in points, of the left edge of the chart. |
Top | Optional | Single | The position, measured in points, of the top edge of the chart. |
Width | Optional | Single | The width of the chart, measured in points. |
Height | Optional | Single | The height of the chart, measured in points. |
NewLayout | Optional | Boolean | NewLayout is not used in Project. |
Style | Optional | INT | |
Type | Optional | XLCHARTTYPE | |
Left | Optional | FLOAT | |
Top | Optional | FLOAT | |
Width | Optional | FLOAT | |
Height | Optional | FLOAT | |
NewLayout | Optional | BOOL | |
Name | Required/Optional | Data type | Description |
Shape
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
Shapes Object Shape Object Chart Object
[!includeSupport and feedback]