bob.mazzo
bob.mazzo

Reputation: 5637

In Excel VBA 2010: How to destroy excel vba.application object

I have an Excel.Application object which seems to live on as a Windows Process AFTER my VBA code has executed and Excel 2010 is completely closed out. i.e. Windows Task Manager shows the Process as "EXCEL.EXE *32", even after I've closed Excel.

Here's some code below :

Public Sub Test Dim xls As Object

Set xls = CreateObject("Excel.Application")
Set wb = xls.Workbooks.Add

fullFilePath = importFolderPath & "\" & "A1"
wb.SaveAs fullFilePath, AccessMode:=xlExclusive    ' SAVE WORKBOOK AND CLOSE !
wb.Close (True)

' question: How can I destroy the xls object ????

end sub

Basically I can't figure out how to destroy the "xls" I've created in my code. And as I've stated above, it causes EXCEL.EXE *32 to live on as a windows process.

thanks in advance.... Bob

Upvotes: 0

Views: 2564

Answers (1)

Mark PM
Mark PM

Reputation: 2919

Use xls.Quit after you close the workbook

Upvotes: 7

Related Questions