Edit

Share via


Chart.Axes method (Word)

Returns a collection of axes on the chart.

Syntax

expression.Axes (Type, AxisGroup)

expression A variable that represents a Chart object.

Parameters

Name Required/Optional Data type Description
Type Optional Variant The axis to return. Can be one of the following XlAxisType constants: xlValue, xlCategory, or xlSeriesAxis (xlSeriesAxis is valid only for 3D charts).
AxisGroup Optional XlAxisGroup One of the enumeration values that specifies the axis group. The default is xlPrimary.

Note

3D charts have only one axis group.

|

Return value

An Axes object that contains the selected axes from the chart.

Example

The following example adds an axis label to the category axis for the first chart in the active document.

With ActiveDocument.InlineShapes(1) 
    If .HasChart Then 
        With .Chart.Axes(xlCategory) 
            .HasTitle = True 
            .AxisTitle.Text = "July Sales" 
        End With 
    End If 
End With

The following example turns off major gridlines in the category axis for the first chart in the active document.

With ActiveDocument.InlineShapes(1) 
    If .HasChart Then 
        .Chart.Axes(xlCategory). _ 
            HasMajorGridlines = False 
    End If 
End With

The following example turns off all gridlines for all axes in the first chart of the active document.

With ActiveDocument.InlineShapes(1) 
    If .HasChart Then 
        For Each a In .Chart.Axes 
            a.HasMajorGridlines = False 
            a.HasMinorGridlines = False 
        Next 
    End If 
End With

See also

Chart Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.