Class Chart (PowerPoint VBA)

The class Chart represents a chart in a presentation.

The main procedures of class Chart are Copy, Delete and Select

Set

To use a Chart class variable it first needs to be instantiated, for example

Dim chr as Chart
Set chr = ActiveWindow.RangeFromPoint.Chart

The following procedures can be used to set variables of type Chart: Shape.Chart and ShapeRange.Chart

Themes

Some procedures in this class have been grouped together in themes and are described on separate theme pages

Data with its procedures ApplyDataLabels, ChartData, DataTable, HasDataTable and SetSourceData
Format with its procedures ApplyLayout, ChartColor, ChartStyle, ClearToMatchColorStyle, ClearToMatchStyle, Format, HeightPercent and PlotVisibleOnly
Name with its procedures ChartTitle, HasTitle, Name and Title
Copy with its procedures Copy and CopyPicture
Display/Show with its procedures DisplayBlanksAs, ShowAllFieldButtons, ShowDataLabelsOverMaximum and ShowLegendFieldButtons
Axis with its procedures HasAxis and ShowAxisFieldButtons

Methods

These are the main methods of the Chart class

Delete - Deletes the object.

ActiveWindow.RangeFromPoint.Chart.Delete

Select - Selects the object.

ActiveWindow.RangeFromPoint.Chart.Select

Other Methods

Axes - Returns a collection of axes on the chart.

Dim axs As Axes
Set axs = ActivePresentation.Slides(1).Shapes(1).Chart.Axes()

ChartWizard - Modifies the properties of the given chart. You can use this method to quickly format a chart without setting all the individual properties. This method is noninteractive, and it changes only the specified properties.

ActivePresentation.Slides(1).Shapes(1).Chart.ChartWizard

Export - Exports the chart in a graphic format.

Dim strFileName As String: strFileName = 
Dim booExport As Boolean
booExport = ActivePresentation.Slides(1).Shapes(1).Chart.Export(FileName:=strFileName)

GetChartElement - Returns information about the chart element at the specified x-coordinate and y-coordinate.

Dim lngX As Long: lngX = 
Dim lngY As Long: lngY = 
Dim lngElementID As Long: lngElementID = 
Dim lngArg1 As Long: lngArg1 = 
Dim lngArg2 As Long: lngArg2 = 
ActiveWindow.RangeFromPoint.Chart.GetChartElement X:=lngX, Y:=lngY, ElementID:=lngElementID, Arg1:=lngArg1, Arg2:=lngArg2

SetProperty -

Dim strId As String: strId = 
ActiveWindow.RangeFromPoint.Chart.SetProperty Id:=strId, Value:=

Properties

AlternativeText returns or sets the alternative text associated with a shape in a Web presentation.

ActivePresentation.Slides(1).Shapes(1).Chart.AlternativeText = "Bla bla"

AutoScaling true if Microsoft Word scales a 3D chart so that it is closer in size to the equivalent 2D chart. The RightAngleAxes property must be True.

ActivePresentation.Slides(1).Shapes(1).Chart.AutoScaling = True

BackWall returns an object that allows the user to individually format the back wall of a 3D chart.

Dim wllsBackWall As Walls
Set wllsBackWall = ActiveWindow.RangeFromPoint.Chart.BackWall

BarShape returns or sets the shape used for every series in a 3D bar or column chart.

ActivePresentation.Slides(1).Shapes(1).Chart.BarShape = xlBox

CategoryLabelLevel returns or sets an XlCategoryLabel constant that specifies the source level of the chart category labels.

ActiveWindow.RangeFromPoint.Chart.CategoryLabelLevel = xlCategoryLabelLevelAll

ChartArea returns the complete chart area for the chart.

Dim caaChartArea As ChartArea
Set caaChartArea = ActivePresentation.Slides(1).Shapes(1).Chart.ChartArea

ChartType returns or sets the chart type.

ActivePresentation.Slides(1).Shapes(1).Chart.ChartType = xlColumnClustered

DepthPercent returns or sets the depth of a 3D chart as a percentage of the chart width (between 20 and 2000 percent).

ActivePresentation.Slides(1).Shapes(1).Chart.DepthPercent = 50

Elevation returns or sets the elevation, in degrees, of the 3D chart view.

ActivePresentation.Slides(1).Shapes(1).Chart.Elevation = 32

Floor returns the floor of the 3D chart.

Dim flrFloor As Floor
Set flrFloor = ActivePresentation.Slides(1).Shapes(1).Chart.Floor

GapDepth returns or sets the distance, as a percentage of the marker width, between the data series in a 3D chart.

ActivePresentation.Slides(1).Shapes(1).Chart.GapDepth = 200

HasLegend true if the chart has a legend.

ActivePresentation.Slides(1).Shapes(1).Chart.HasLegend = True

Legend returns the legend for the chart.

Dim lgnLegend As Legend
Set lgnLegend = ActivePresentation.Slides(1).Shapes(1).Chart.Legend

Parent returns the parent for the specified object. Read-only object.

Dim objParent As Object
Set objParent = ActiveWindow.RangeFromPoint.Chart.Parent

Perspective returns or sets the perspective for the 3D chart view.

ActivePresentation.Slides(1).Shapes(1).Chart.Perspective = 70

PlotArea returns the plot area of a chart.

Dim paaPlotArea As PlotArea
Set paaPlotArea = ActivePresentation.Slides(1).Shapes(1).Chart.PlotArea

PlotBy returns or sets the way columns or rows are used as data series on the chart.

ActivePresentation.Slides(1).Shapes(1).Chart.PlotBy = xlColumns

RightAngleAxes true if the chart axes are at right angles, independent of chart rotation or elevation. Read/write Boolean.

ActivePresentation.Slides(1).Shapes(1).Chart.RightAngleAxes = True

Rotation returns or sets the rotation, in degrees, of the 3D chart view (the rotation of the plot area around the z-axis). Read/write Variant.

ActivePresentation.Slides(1).Shapes(1).Chart.Rotation = 45

SeriesNameLevel returns or sets an XlSeriesNameLevel constant that specifies the source level of the series names.

ActiveWindow.RangeFromPoint.Chart.SeriesNameLevel = xlSeriesNameLevelAll

Shapes returns a collection that represents all the shapes on the chart sheet.

Dim shpsShapes As Shapes
Set shpsShapes = ActiveWindow.RangeFromPoint.Chart.Shapes

ShowReportFilterFieldButtons returns or sets a value that indicates whether to display the report filter field buttons on a PivotChart.

ActiveWindow.RangeFromPoint.Chart.ShowReportFilterFieldButtons = True

ShowValueFieldButtons returns or sets a value that indicates whether to display the value field buttons on a PivotChart.

ActiveWindow.RangeFromPoint.Chart.ShowValueFieldButtons = True

SideWall returns a Walls object that allows the user to individually format the side wall of a 3D chart.

Dim wllsSideWall As Walls
Set wllsSideWall = ActiveWindow.RangeFromPoint.Chart.SideWall

Walls returns the walls of the 3D chart.

Dim wllsWalls As Walls
Set wllsWalls = ActivePresentation.Slides(1).Shapes(1).Chart.Walls