Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to reuse Excel instance or erase it from memory
Message
 
To
30/05/2009 19:18:37
General information
Forum:
Microsoft Office
Category:
Excel
Miscellaneous
Thread ID:
01402808
Message ID:
01402956
Views:
58
>I am developing a routine that creates excel workbooks using automation. Some of them are temporary but even though I close the book and try to quit excel I am accumulating instances of Excel which are using up memory doing nothing. How can I either close an unneded instance or reuse it?
>
>TIA,
>
>Alex

It depends. The cleanest way to close Excel is to close its childs first (if, say, you declare objects like oWorkBook or oWorkSheet, etc). Then you can close Excel releasing it and taking care of the variable:

oExcel.Quit
oExcel=null
release oExcel

If you close Excel, then in some cases you can reuse it:

if type("oExcel")="O" and not isnull(oExcel)
......

Also you can try:
on Error ll=.t.
ll=.f.
oExcel=GetObject(,"Excel.Application")
on error
if ll
oExcel=CreateObject("Excel.Application")
.....


Good Luck
Previous
Reply
Map
View

Click here to load this message in the networking platform