This documentation is archived and is not being maintained.

Chart.SetElement Method

Office 2007
Sets chart elements on a chart. Read/write MsoChartElementType.

Version Information
 Version Added:  Excel 2007

Syntax

expression.SetElement(Element)

expression   A variable that represents a Chart object.

Parameters

NameRequired/OptionalData TypeDescription
ElementRequiredMsoChartElementTypeSpecifies the chart element type.

Return Value
Nothing

Remarks

For charts, the following commands in the Layout tab correspond to the SetElement method:

  • Everything in the Labels group.
  • Everything in the Axes group.
  • Everything in the Analysis group.
  • PlotArea, Chart Wall, and Chart Floor buttons.

MsoChartElementType is an enumeration of constants that refer to all of the above commands.

Example

This example sets chart elements using the various constant values to an active chart.

Visual Basic for Applications
ActiveChart.Axes(xlValue).MajorGridlines.Select
    ActiveChart.SetElement (msoElementChartTitleCenteredOverlay)
    ActiveChart.SetElement (msoElementPrimaryCategoryGridLinesMinor)
    ActiveChart.Walls.Select
    Application.CommandBars("Clip Art").Visible = False
    ActiveChart.SetElement (msoElementChartFloorShow)



Show: