>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only