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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Process won't Quit

Status
Not open for further replies.

myan

Programmer
Feb 12, 2002
8
GB
I have a cutsom Class which handles my excel functions
I have an import class which handles my imports

When I want to Quit the excel process during Automation I call this.objExcel.Application.quit

However the process is still running (task list)
I thought the problem might be in the release of the object
in my Excel Class Destroy I have

this.objExcel = null
RELEASE objExcel

This does not end the process!

Any ideas?
Need more info!

Many thanks
 
myan

Normally you would use:
PUBLIC oExcel
oExcel = CREATEOBJECT("Excel.application")
oExcel.quit
oExcel=.NULL.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
The Quit is part of my close and does work if I call it proir to doing any work with Excel.

What would keep the Excel Process running.

References still held would these keep it open?
 
myan

What would keep the Excel Process running.

It is possible that Excel did not finish it's wor before you are trying to quit.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
In all of our Excel automation programs we use the following statements and have no problems

*---start Excel
oExcel=CreateObject("Excel.Application")




*----end Excel
oExcel.quit
Release oExcel

 
After much angst..
my problem was a routine I had for finding the name of a sheet based on its index number.

My Failing code:
Code:
WITH this.objExcel
  For Each ws In .Worksheets
   lnCnt = lnCnt +1 
   IF lnCnt = lnSheet then
     lcSheetname  = ws.name
   ENDIF
  NEXT	
  Release ws	
ENDWITH

My Working Code
Code:
lnSheets = this.objExcel.Worksheets.count
FOR lnCnt = 1 TO lnSheets 		
  IF lnCnt = lnSheet then
    lcSheetname = this.objExcel.worksheets(lnCnt).name
    EXIT
  ENDIF			
NEXT

The non working code must be holding a reference to the Excel Application and stopping it from closing on Quit

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top