Excel 2007 chart gridline color using vba

  • Thread starter Thread starter maximilianberger
  • Start date Start date
M

maximilianberger

Hello,
i want to apply a themecolor to a chart gridline using vba. I can
apply normal colors (RGB, index) but not the theme color. Any idea?

thx.
berg
 
Hi,

Here are the various ways fo changing the colour.

With ActiveChart
With .Axes(xlValue, xlPrimary)
If .HasMajorGridlines Then
With .MajorGridlines
.Border.ColorIndex = 5 'set color to blue
.Border.Color = RGB(0, 255, 0) ' green
.Format.Line.ForeColor.ObjectThemeColor =
msoThemeColorAccent2
End With
End If
End With
End With

Cheers
Andy
 
Hi,

Here are the various ways fo changing the colour.

    With ActiveChart
        With .Axes(xlValue, xlPrimary)
            If .HasMajorGridlines Then
                With .MajorGridlines
                    .Border.ColorIndex = 5    'set color to blue
                    .Border.Color = RGB(0, 255, 0) ' green
                    .Format.Line.ForeColor.ObjectThemeColor =
msoThemeColorAccent2
                End With
            End If
        End With
    End With

Cheers
Andy

Thank you!
 
Back
Top