Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel out of memory

Status
Not open for further replies.

wawalter

Programmer
Aug 2, 2001
125
0
0
US
Hello,

I need to create about 1,000 excel files. It works fine through about 300 or so then I get the following error:

Not enough memory to run Microsoft Office Excel

I then have to reboot my computer and run another 300 or so then repeat. Just closing the application doesn't fix the error, I have to reboot.

There are no instances of Excel open according to the task manager and it looks like I have plenty of available memory.

Anybody have any ideas of how to avoid this or an alternative way of creating the excel files without using the excel object that maybe won't have this problem?

Thanks,
Bill
 
there is a good chance you are not disposing of either excel or the workbook object after you are finished with them. if the excel/workbook object implements IDisposable then you can call Dispose(); after closing it. or using the "using" keyword.
example: (the objects/members may be incorrect, the concept is for disposing)
Code:
using(var excel = new ExcelObject())
{
   using(var workbook = excel.Open("the workbook"))
   {
      workbook.Close();
   }
   excel.Exit();
}

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
I tried using the using, but apparently the Excel object doesn't implement IDispose so I don't think I can use that method.

I thought I'd try only creating one excel object and doing save as then clearing the excel sheet instead of creating a new excel object everytime through the loop. Maybe that will get me around the problem.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top