Chart Title Object Example

This example adds a chart title to a chart and formats it:

Sub AddAndFormatChartTitle()

Dim oCT As ChartTitle

'Make sure the chart has a title

Charts(1).HasTitle = True

'Get the ChartTitle object

Set oCT = Charts(1).ChartTitle

'Format the chart title

With oCT

.Caption = "Hello World"

.Font.Name = "Times New Roman"

.Font.Size = 16

.Characters(1, 1).Font.Color = RGB'

(255,

0, 0)

.Characters(7, 1).Font.Color = RGB

(255,

0, 0)

.Border.LineStyle = xlContinuous

.Border.Weight = xlThin

.Shadow = True

End With

End Sub

0 0

Post a comment