View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default Interrupted sheet copying causes phantom Book2

I didn't try it, but do you have trouble if you change calculation to manual,
then copy the sheet, then change it to automatic?



Dan Williams wrote:

Run this with a sheet1 that has enough calculations to make the copying
non-instantaneous.

Sheets("sheet1").Copy

If you press ESC quickly enough during the copying, you get a
not-surprising error: "Copy method of Worksheet class failed." That's
fine.

However, if sheet1 has a pie chart in it, then the next time you exit
from Excel, you get:

"Do you want to save the changes you made to 'Book2'?"

and if you naively say "Yes," Excel crashes. (And if you've tested it
several times before exiting, it also asks you about Book3, Book4,
etc.)

When I trap the ESC key, the trapping works fine, but the same error
happens when I exit Excel anyway.

I was building a mechanism to allow users to interrupt a tiresome loop,
but this makes me afraid to suggest using the ESC key at all. They
could lose stuff in other open workbooks.

I'm guessing I'm just going to have to live with this. Perhaps I'll
have to re-assemble the pie chart after each copy. But I thought I'd
at least document it.

Dan Williams
<danwPlanet


--

Dave Peterson