ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to set the text in a textbox in a chart object with VBA? (https://www.excelbanter.com/excel-programming/431248-how-set-text-textbox-chart-object-vba.html)

DHB7

How to set the text in a textbox in a chart object with VBA?
 
I've a textbox I wish to fill programmatically on a chart. I can get to the
Shape object I need and when viewing this in the locals window there's a
DrawingObject property which you cannot get at via VBA. If I can get a hold
of this object I can change the text, but I just cannot find a way of
procuring an appropriate object!

Patrick Molloy

How to set the text in a textbox in a chart object with VBA?
 
Option Explicit

Sub addtext()
Dim ch As ChartObject
Set ch = Sheet1.ChartObjects(1)
With ch.Chart.TextBoxes.Add(193, 121, 26, 14)
.Select
.AutoSize = True
.Text = "hello"
End With
End Sub


"DHB7" wrote in message
...
I've a textbox I wish to fill programmatically on a chart. I can get to
the
Shape object I need and when viewing this in the locals window there's a
DrawingObject property which you cannot get at via VBA. If I can get a
hold
of this object I can change the text, but I just cannot find a way of
procuring an appropriate object!




All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com