Excel Crash caused by VB Macro

  • Thread starter Thread starter Jules
  • Start date Start date
J

Jules

I am running Excel 2000 9.0.6926 SP-3

I have a VB macro with a "FOR" loop that opens each file
in a specified folder (files previously found using
the "Application.FileSearch" command), processes data from
the file into a worksheet, then closes the file without
saving it.

Intermittently, Excel crashes with the following error

EXCEL.EXE Application Error
The instruction at "0x6500bc82" referenced memory
at "0x02367d2c". The memory could not be "read".

This intermittent error is not dependent on the file being
processed, nor the number of files that have been
processed. Through the additiona of diagnostic code I
believe that the error, when it occurs, is close to the
point where the file is closed at the end of the "FOR"
loop. Here is the VB code used to close the file:-

ActiveWorkbook.Close SaveChanges:=False

The problem occurs about once every ten times the macro is
run, and has proved to be very resistent to changes or
restructing made to the VB code

Any assistance would be welcomed
 
have you got a doevents in your loop?
Often this error is because excel still holds a reference
to part of a file, which then closes, making the memory
address invalid.
doevents lets windows clear up a bit
cheers
Simon
 
Simon,
Many thanks for your suggestion - I have now added a
DoEvents statement immediately after closing the file at
the end of the DO loop - Excel has not crashed again so
far, but will need more testing to prove this has solved
the problem

Jules
 
The doevents statement did not solve my problem, but what
did was a move to MS Office 2003 - since installing that
three weeks ago I have had no more Excel crashes
Thanks for your help
Jules
 
Back
Top