Object doesn't support this property or method

R

Rick Campbell

I am trying to add a text box to all my charts. I want to move the text box
to the lower right corner. My macro keeps returning this error at the point
in the macro where the text box gets moved and re-shaped. Any help would be
greatly appreciated.

Option Explicit

Sub Copyright()

Dim chtobj As ChartObject
For Each chtobj In ActiveSheet.ChartObjects
With chtobj.Chart.TextBoxes.Add(131, 80, 86, 17)
.Select
.AutoSize = True
.Formula = "='12 Charts'!$O$2"
End With
Selection.ShapeRange.IncrementLeft 45.74
Selection.ShapeRange.IncrementTop 64.49
Selection.ShapeRange.ScaleHeight 0.73, msoFalse, msoScaleFromBottomRight
Next chtobj
End Sub
 
T

Tom Ogilvy

Sub aa_Tester9()
Dim chtobj As ChartObject
Dim tbox As TextBox
For Each chtobj In ActiveSheet.ChartObjects
Set tbox = chtobj.Chart.TextBoxes.Add(131, 80, 86, 17)
With tbox
.Select
.AutoSize = True
.Formula = "='12 Charts'!$O$2"
End With
With chtobj.Chart.Shapes(tbox.Name)
.IncrementLeft 45.74
.IncrementTop 64.49
.ScaleHeight 0.73, msoFalse, msoScaleFromBottomRight
End With
Next chtobj
End Sub


Worked for me.

Regards,
Tom Ogilvy
 
R

Rick Campbell

Thanks Tom! Works like a charm.

Rick

Tom Ogilvy said:
Sub aa_Tester9()
Dim chtobj As ChartObject
Dim tbox As TextBox
For Each chtobj In ActiveSheet.ChartObjects
Set tbox = chtobj.Chart.TextBoxes.Add(131, 80, 86, 17)
With tbox
.Select
.AutoSize = True
.Formula = "='12 Charts'!$O$2"
End With
With chtobj.Chart.Shapes(tbox.Name)
.IncrementLeft 45.74
.IncrementTop 64.49
.ScaleHeight 0.73, msoFalse, msoScaleFromBottomRight
End With
Next chtobj
End Sub


Worked for me.

Regards,
Tom Ogilvy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top