?
Solved

Problem upgrading VBA from MS Excel 2003 to 2010

Posted on 2014-10-29
7
Medium Priority
?
239 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 52

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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 2000 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

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.

Question has a verified solution.

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

I recently resolved a client's Office 2013 installation problem and wanted to offer an observation that may help you with troubleshooting similar issues. The client ordered three Dell Optiplex system units with the Windows 7 downgrade option inst…
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

764 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