cut/paste a chart with a Macro?


Posted by Ted on May 02, 2000 10:14 AM

When trying to cut a chart and then paste it in a different location on the same
work sheet with a macro I get a Error."Unable to get ChartObjects property of
the worksheet class".
This is the macro I tried to use but got an error "Unable to get ChartObjects
property of the worksheet class".I ran debug ( it pointed to the part I
marked***).Thanks for any help.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 5/1/2000 by
'

'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
ActiveWindow.WindowState = xlNormal
ActiveWindow.WindowState = xlMaximized
Range("F2").Select
*** ActiveSheet.ChartObjects("Chart 2").Activate ***
ActiveChart.Paste
End Sub




Posted by Celia on May 03, 2000 4:56 AM

Macro1 Macro Macro recorded 5/1/2000 by

Ted
I must admit to having no experience with charts but it would seem that if you just want to relocate your chart to cell F2 you should be using code to relocate rather than cut and paste.

The following should work :-

Sub RelocateChart()
ActiveSheet.Shapes("Chart 1").Left = Range("F2").Left
ActiveSheet.Shapes("Chart 1").Top = Range("F2").Top
End Sub

Celia