Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
gerhardl
Creator II
Creator II

Excel not quitting properly from macro

Hi There,

I do certain excel reports via QlikView macros. They create the reports and then quit excel.

But I still have instances of EXCEL.EXE*32 showing up in my task manager's processes.

These reports run automatically every morning, so every few days I find myself opening TM and ending up to 5 or 10 instances of excel, even though the application isn't actually "open".

Any ideas?

My macros end with:

XLDoc.SaveAs NewFileName

XLApp.Quit

End Sub

4 Replies
Anonymous
Not applicable

Hi,

Not really QlikView related so I went searching for excel/vbscript questions on google and found these two posts that might help you:

This one seems to be due to the fact that the workbook is not closed before killing the excel application

http://www.vbforums.com/showthread.php?680397-RESOLVED-Excel.exe-not-closing-after-setting-objects-n...

This one has some general advice on cleaning up before killing excel that might help. There's also a workaround in the form of a piece of vbscript that will kill any Excel processes when ran

http://social.msdn.microsoft.com/Forums/en-US/exceldev/thread/93958cdb-1a4d-490b-9e47-5be25e430a21/

gerhardl
Creator II
Creator II
Author

Hi Johannes,

I've now tried different variations of closing the file and doing s cleanup after, and still no luck. Same result.

XLDoc.SaveAs NewFileName

XLDoc.Close 'test

XLApp.Quit

SET XLApp = nothing 'test

SET XLDoc = nothing 'test

End Sub

gerhardl
Creator II
Creator II
Author

Okay I found my (stupid) problem.

I had two different places in the code where I was repeating this:

SET XLApp = CreateObject("Excel.Application")

And then I was just quitting one instance of excel. Deleting the duplicate line sorted this out.

Thanks for the help.

G

dirk1955
Creator
Creator

This is not working for me.

strFile = "F:\B-FS102\GSM\Facturen\Facturatie\" & strValueToDisplay & "_" & strvID &".xlsx"

' Save and quit  

  objExcelWorkbook.SaveAs strFile  

    objExcelWorkbook.Close

    objExcelApp.close

  

    objExcelApp.quit

     

    SET objExcelWorkbook = NOTHING        

    SET objExcelApp = NOTHING 

Leaves excel open.

The file close but excel remains open.

Help anyone.