Tuesday, November 27, 2007

check if a excel chart as a legend in vba

hi people, i had a problem with a vba script and i needed to check if a chart in excel had a legend active.

for that, use this code:

If ActiveChart.HasLegend Then
Selection.AutoScaleFont = False
With Selection.Font
.Name = "Arial"
.FontStyle = "normal"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = True
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With

'With Selection.Border
' .Weight = xlHairline
' .LineStyle = xlAutomatic
'End With
Selection.Shadow = True
End If

No comments: