ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Shapes (https://www.excelbanter.com/excel-programming/351247-shapes.html)

Steven Drenker[_4_]

Shapes
 
I want to add a shape to a chart and control the text in the shape as
follows:

Dim shpDate As Shape

Set shpDate = ActiveChart.Shapes.AddTextbox(msoTextOrientationHo rizontal, 5,
20, 120, 30)
With shpDate
.Name = "Text Box Date"
.Characters.Text = Worksheets("D1.Ptin vs Comp").Range("A2") '<-- ERROR
End With

Apparently I am not allowed to access the .Characters.Text property of a
shape object. Instead I have to first select the shape and use the
selection:

ShpDate.select
Selection.Characters.Text = Worksheets("D1.Ptin vs Comp").Range("A2")

This seems awkward. When I have the shape object (shpDate), why can't I just
access it directly? Why do I have to use the indirect method of first
selecting the shape, then accessing the Characters.Text property?

Thanks!
Steve


Jim Cone

Shapes
 
Steve,

Try...
shpDate.TextFrame.Characters.Text = "Never Upgrade"

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Steven Drenker" wrote in message
...
I want to add a shape to a chart and control the text in the shape as
follows:

Dim shpDate As Shape
Set shpDate = ActiveChart.Shapes.AddTextbox(msoTextOrientationHo rizontal, 5,
20, 120, 30)
With shpDate
.Name = "Text Box Date"
.Characters.Text = Worksheets("D1.Ptin vs Comp").Range("A2") '<-- ERROR
End With

Apparently I am not allowed to access the .Characters.Text property of a
shape object. Instead I have to first select the shape and use the
selection:
ShpDate.select
Selection.Characters.Text = Worksheets("D1.Ptin vs Comp").Range("A2")
This seems awkward. When I have the shape object (shpDate), why can't I just
access it directly? Why do I have to use the indirect method of first
selecting the shape, then accessing the Characters.Text property?
Thanks!
Steve



All times are GMT +1. The time now is 07:51 PM.

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