Text Box in Chart

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hello,
I have a chart where I want to add some information about the chart (like
average, etc.). I am doing this by adding a text box to the chart. I ran
into the problem that sometime the text box would appear and sometime it
would not. It appears that it will appear if there are less than 255
characters in the text box and not if there are more. Differences occur due
to rounding and different number of decimal places. Below is part of the
code I am using. Any reasons for this?

Thanks,

Bill


ActiveChart.TextBoxes.Add(ChWidth - 0.125 * ChWidth, Chtop - 0.1 * Chtop,
10, 10).Select

Selection.Name = "ds"

ActiveChart.Shapes("ds").Select



Selection.Characters.Text = "Info" & Chr(10) _

& "Sigma= " & Application.Round(SD, NDP) & Chr(10) _

& "Average=" & Application.Round(Xbar, NDP) & Chr(10) _

& "Min=" & Application.Round(MinHist, NDP) & Chr(10) _

& "Max=" & Application.Round(MaxHist, NDP) & Chr(10) _





Etc. etc.
 
Indeed can't put more than 255 characters in a textbox in one go, need to
add in chuncks

untested -

sText = make your long string here

With ActiveChart.TextBoxes.Add(ChWidth - 0.125 * ChWidth, Chtop - 0.1 *
Chtop,
j = 1
Do While j < Len(sText)
sPart = Mid$(sText, j, 250)
.TextFrame.Characters(j).Insert String:=sPart
j = j + 250
Loop
End With

Regards,
Peter T
 
Back
Top