Solved

Problem upgrading VBA from MS Excel 2003 to 2010

Posted on 2014-10-29
7
234 Views
Last Modified: 2014-10-29
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
Comment
Question by:Frans_Truyens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 40410422
Hi,

pls try

    For Each shp In ActiveChart.Shapes
            shp.Delete
    Next


Regards
0
 
LVL 2

Expert Comment

by:Glen Richmond
ID: 40410423
try direct obj ref

dim myObj as object

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

myObj.Delete

Open in new window

0
 

Author Comment

by:Frans_Truyens
ID: 40410436
I don't want to delete the graph. Only the contents, the drawingobjects on it.
0
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40410463
Have you tried my code?

worksheets("ABC").ChartObjects("Graph1").Activate
For Each shp In ActiveChart.Shapes
    shp.Delete
Next
0
 

Author Comment

by:Frans_Truyens
ID: 40410507
Rgonzo1971
We are trying it now.
0
 

Author Comment

by:Frans_Truyens
ID: 40410525
It works! Thanks a lot.
0
 

Author Closing Comment

by:Frans_Truyens
ID: 40410527
Thanks a lot
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As freelancing is becoming more and more common in the tech industry, certain obstacles are proving to be a challenge to those who are used to more traditional, structured employment. This article is meant to help identify such obstacles and offer a…
When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question