Hi Paul,
I have the feeling that the previous answers are not what you are after. I
am assuming that the Text Box is created from the Drawing toolbar because I
don't believe that text boxes from either the forms toolbar or control
toolbox can be placed on a chart.
I recorded code in xl2002 to place a value in a drawing text box. (It would
not record in xl2007 but under test the code will work in an xl2007 file). I
have not been able to modify the code to obtain the desired results without
having the code select the text box so below is what I finished up with. You
should be able to modify it for your requirements. I also included a little
extra for inserting source data, the chart title and X and Y axis titles and
I left the recorded code in for formatting the text in the text box in case
that helps also.
I am interested if anyone knows how to modify the code so that it is not
actually necessary to select the text box.
Sub ChartTitles()
Dim tday As String
'Dummy value created for tday for the exercise
tday = Format(Date, "dd mmm yyyy")
Worksheets("Graph").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Shapes("Text Box 2").Select
Selection.Characters.Text = tday
Selection.AutoScaleFont = False
With Selection.Characters(Start:=1, Length:=16).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
'Some added extra info if required
With Worksheets("Graph") _
.ChartObjects("Chart 1").Chart
'ChartSeriesRange is a named range on the worksheet
.SetSourceData Source:=Sheets("Calc") _
.Range("ChartSeriesRnge"), PlotBy:=xlRows
.HasTitle = True
.ChartTitle.Characters.Text = "My Chart Title"
.ChartTitle.Font.Bold = True
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle. _
Characters.Text = "My X Axis"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle. _
Characters.Text = "My Y Axis"
End With
End Sub