Link to home
Start Free TrialLog in
Avatar of Frans_Truyens
Frans_TruyensFlag for Belgium

asked on

Problem upgrading VBA from MS Excel 2003 to 2010

I have a problem upgrading code from MS Excel 2003 to MS Excel 2010. Below lines work fine in 2003, but don't work in 2010. Please help

worksheets("ABC").ChartObjects("Graph1").Activate
ActiveChart.DrawingObjects.Delete

The first line works, but when I want to delete all drawingobjects on the graph, it gives an error: 'Method delete of class DrawingObjects failed'. Do you have code to remove all objects inside the graph?
Avatar of Rgonzo1971
Rgonzo1971

Hi,

pls try

    For Each shp In ActiveChart.Shapes
            shp.Delete
    Next


Regards
try direct obj ref

dim myObj as object

set myObj = worksheets("ABC").ChartObjects("Graph1")

myObj.Delete

Open in new window

Avatar of Frans_Truyens

ASKER

I don't want to delete the graph. Only the contents, the drawingobjects on it.
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Rgonzo1971
We are trying it now.
It works! Thanks a lot.
Thanks a lot