PC Review Forums Newsgroups Microsoft Excel Microsoft Excel Crashes EXCEL 2003 - Run Time Error... want a challenge !

Reply

EXCEL 2003 - Run Time Error... want a challenge !

 
Thread Tools Rate Thread
Old 20-04-2005, 02:04 AM   #1
=?Utf-8?B?S25pZ2h0U3VyZmVy?=
Guest
 
Posts: n/a
Default EXCEL 2003 - Run Time Error... want a challenge !


Greetings,

Heres a challenge, i cant find a solution to this anywhere.

In EXCEL.

Ive got VB code to copy a Template of a Chart, and then populate it with data.
It needs to create about 40-45 graphs... i do this every monday so its
automated for that reason.

anyway, if it creates over around 39 graphs, i get this error:
-----
Run-time error '1004'
copy method of Chart class failed.
-----

This is the line of code is stops on.

Sheets("TEMPLATE").Select
Sheets("TEMPLATE").Copy after:=Sheets(Sheets.Count)

Sheets("TEMPLATE (2)").Select
Sheets("TEMPLATE (2)").Name = KPR_Sheet

-------

Any help would be great.

if i save and close the spreadsheet, it seems to reset the error. ie if i
restart it after i have opened it, i can get another 40 odd sheets before it
fails.




  Reply With Quote
Old 20-04-2005, 07:25 AM   #2
Jan Karel Pieterse
Guest
 
Posts: n/a
Default Re: EXCEL 2003 - Run Time Error... want a challenge !

Hi KnightSurfer,

> Ive got VB code to copy a Template of a Chart, and then populate it with data.
> It needs to create about 40-45 graphs... i do this every monday so its
> automated for that reason.
>

I'm afraid you've hit a problem with Excel here. Copying sheets with charts on
them (or chart sheets) has a memory leak on certain Excel versions, which indeed
can only be solved by restarting Excel.

Since you seem to be copying the same chart over and over, why not create that
chart based on dynamic data. Instead of changing to a different chart sheet, let
the user change the source data using e.g. dropdown boxes or spinner controls.
See my Autochrt.zip for a simple example. Find it on this page:

http://www/jkp-ads.com/Download.htm

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com

  Reply With Quote
Old 20-04-2005, 07:43 AM   #3
Bill Manville
Guest
 
Posts: n/a
Default Re: EXCEL 2003 - Run Time Error... want a challenge !

Not sure what the cause is; maybe Excel is not releasing some
resources. If you don't need the charts to be live, you could make one
chart and then copy a picture of it to another sheet and then reuse the
same chart with the next data. I have done similar things in the past
using pictures of charts and have not experienced a problem.


Bill Manville
MVP - Microsoft Excel, Oxford, England

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off