2002 Vs 2003

A

Ardy

Hello All:
I have this code that is for deleting graphs(Charts). Can anybody
tell me why this works in 2002 but gives me error in 2003. for some
reason the 2003 has problem with chObj



Dim ch As Chart, ws As Worksheet
Dim cw As Long, rh As Long
Dim chObj As ChartObject

' ----------------Delete Existing Charts--------------------
Application.DisplayAlerts = False
For Each ch In ActiveWorkbook.Charts
ch.Delete
Next
For Each ws In ActiveWorkbook.Worksheets
For Each chObj In ws.ChartObjects
chObj.Delete
Next
Next
Application.DisplayAlerts = True
' ---------------Delete Existing Charts----------------------
 
J

Jim Cone

It works for me in both versions.
Are some of the sheets protected in the xl2003 version?
What is the error?
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel add-ins)



"Ardy" <[email protected]>
wrote in message Hello All:
I have this code that is for deleting graphs(Charts). Can anybody
tell me why this works in 2002 but gives me error in 2003. for some
reason the 2003 has problem with chObj

Dim ch As Chart, ws As Worksheet
Dim cw As Long, rh As Long
Dim chObj As ChartObject

' ----------------Delete Existing Charts--------------------
Application.DisplayAlerts = False
For Each ch In ActiveWorkbook.Charts
ch.Delete
Next
For Each ws In ActiveWorkbook.Worksheets
For Each chObj In ws.ChartObjects
chObj.Delete
Next
Next
Application.DisplayAlerts = True
' ---------------Delete Existing Charts----------------------
 
D

Don Guillett

I just tested this in 2003. Should do it all

sub deleteallcharts()
For Each ws In ActiveWorkbook.Worksheets
For Each chObj In ws.ChartObjects
chObj.Delete
Next
Next
end sub
 
A

Ardy

It works for me in both versions.
Are some of the sheets protected in the xl2003 version?
What is the error?
--
Jim Cone
San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
(Excel add-ins)

"Ardy" <[email protected]>
wrote in message Hello All:
I have this code that is for deleting graphs(Charts). Can anybody
tell me why this works in 2002 but gives me error in 2003. for some
reason the 2003 has problem with chObj

Dim ch As Chart, ws As Worksheet
Dim cw As Long, rh As Long
Dim chObj As ChartObject

' ----------------Delete Existing Charts--------------------
Application.DisplayAlerts = False
For Each ch In ActiveWorkbook.Charts
ch.Delete
Next
For Each ws In ActiveWorkbook.Worksheets
For Each chObj In ws.ChartObjects
chObj.Delete
Next
Next
Application.DisplayAlerts = True
' ---------------Delete Existing Charts----------------------

Thanks for reply:
I don't have access to the 2003 version, It is my home version. I
will post the error as soon as I get home today. And yes there are
some protected sheet, but prior to deleting I am unlocking.......I
will post today with error.
 
A

Ardy

I just tested this in 2003. Should do it all

sub deleteallcharts()
For Each ws In ActiveWorkbook.Worksheets
For Each chObj In ws.ChartObjects
chObj.Delete
Next
Next
end sub

OK
I get the compile error, can't find project or library, I don't
understand why I don't get this with 2002 version. any thoughts.......
 
J

Jon Peltier

In the VBE, go to Tools > References, and look for one that's labeled
"MISSING". Uncheck the reference and try again.

Very often things seemingly unrelated to a missing reference will fail.

- Jon
 
A

Ardy

In the VBE, go to Tools > References, and look for one that's labeled
"MISSING". Uncheck the reference and try again.

Very often things seemingly unrelated to a missing reference will fail.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -http://PeltierTech.com
_______

Thanks Jon:
I will try this tonight as soon as I get home, I hope this works. I
will post toinight if this worked.
 
A

Ardy

In the VBE, go to Tools > References, and look for one that's labeled
"MISSING". Uncheck the reference and try again.

Very often things seemingly unrelated to a missing reference will fail.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -http://PeltierTech.com
_______

Worked, Thanks a bunch. Can you explain what this option is
for..........
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top