Excel 2007 chart gridline color using vba

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
 
A

Andy Pope

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
 
M

maximilianberger

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top