LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default ChartObjects Insanity - Excel 2007

Either one of us - me or Excel - is insane, or soon to become so. I
have code I'm trying to convert from Excel 2003, and it's not going
smoothly. Here's the current problem.

I have a workbook with a number of chart sheets, each containing three
charts. I want to delete the third chart from every sheet. I used to
say..

For Each ch In wb.Charts
.....
ch.ChartObjects(3).Delete

Next ch

Now, that tells me I have a subscript out of range. I check, and ?
ch.ChartObjects.count returns a value of 3. I can return the name on
the third chart too, so I try

ch.ChartObjects(ch.ChartObjects(3).Name).Delete

It works. Huh? So it's nuts, but it works. Not quite. It doesn't
produce an error, but it doesn't delete the chart completely either.
It leaves an empty chart box on the page. So I start again and record
a macro just to see what Excel would do. It It comes up with

ActiveSheet.ChartObjects("Chart 7").Activate
ActiveChart.Parent.Delete

I adapt to fit my code and try it, and the whole sheet gets deleted.

Please, someone save my sanity and tell me where I'm going wrong.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 code to use instead of ChartObjects Breck Excel Programming 4 March 2nd 08 10:47 PM
Header Insanity [email protected] Excel Discussion (Misc queries) 2 February 19th 08 07:59 PM
ZIP Code insanity - , How to€¦vlookup, formats, number of digits. Doug929 Excel Programming 3 February 2nd 07 03:25 PM
Excel 2000 Copy worksheet w/ ChartObjects memory leak [email protected] Excel Programming 0 February 3rd 06 12:57 AM
ChartObjects Nick Excel Programming 2 August 19th 04 12:04 PM


All times are GMT +1. The time now is 09:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"