Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

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?
0
Frans_Truyens
Asked:
Frans_Truyens
  • 4
  • 2
1 Solution
 
Rgonzo1971Commented:
Hi,

pls try

    For Each shp In ActiveChart.Shapes
            shp.Delete
    Next


Regards
0
 
Glen RichmondCustomer Reporting Programmer.Commented:
try direct obj ref

dim myObj as object

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

myObj.Delete

Open in new window

0
 
Frans_TruyensAuthor Commented:
I don't want to delete the graph. Only the contents, the drawingobjects on it.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Rgonzo1971Commented:
Have you tried my code?

worksheets("ABC").ChartObjects("Graph1").Activate
For Each shp In ActiveChart.Shapes
    shp.Delete
Next
0
 
Frans_TruyensAuthor Commented:
Rgonzo1971
We are trying it now.
0
 
Frans_TruyensAuthor Commented:
It works! Thanks a lot.
0
 
Frans_TruyensAuthor Commented:
Thanks a lot
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now