ChGridlines Object

Microsoft Office Web Components Object Model

ChGridlines Object

         
ChAxis ChGridlines
ChLine

Represents major or minor gridlines on a chart axis. You cannot have gridlines without an axis. Gridlines extend the tick marks on a chart axis to make it easier to see the values associated with the data markers. This object is not a collection. There is no object that represents a single gridline; you either have all gridlines for an axis turned on or all of them turned off.

Using the ChGridlines object

The following properties return a ChGridlines object.

The ChAxis object’s MajorGridlines property

The ChAxis object’s MinorGridlines property

The following example enables the major and minor gridlines for the value axis in the first chart in Chartspace1. Then, the weight of the gridlines is formatted.

Sub EnableGridlines()

    Dim chConstants
    Dim axValueAxis

    Set chConstants = ChartSpace1.Constants

    ' Set a variable to the value axis in the first chart in Chartspace1.
    Set axValueAxis = ChartSpace1.Charts(0).Axes(chConstants.chAxisPositionValue)

    ' The following two lines of code turn on the major and
    ' minor gridlines for the value axis.
    axValueAxis.HasMajorGridlines = True
    axValueAxis.HasMinorGridlines = True

    ' The following two lines of code set the line weight of the
    ' major and minor gridlines for the value axis.
    axValueAxis.MajorGridlines.Line.Weight = chConstants.owcLineWeightMedium
    axValueAxis.MinorGridlines.Line.Weight = chConstants.owcLineWeightHairline

End Sub