FatBoySlim7
FatBoySlim7

Reputation: 232

Difficult closing the .exe process in excel

I'm building a MS-Excel extract from a VB6 application. I'm having a very difficult time getting rid of the .exe process for excel. I generate an extract and save it to C: drive. I don't open it or anything, yet it's still visible in the Task Manager under Processes. Here is how I declare and close all excel components.

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add

This I do all the way at the end of the procedure

Xlbook.close
Set xlSheetWeek = Nothing
Set xlBook = Nothing
Set xlApp = Nothing

Why is the process still working even though I do all the xlbook.close and Don't have excel open. It shouldn't be showing.

Upvotes: 2

Views: 110

Answers (2)

mrbungle
mrbungle

Reputation: 1931

You can get crazy and

sKill = "TASKKILL /F /IM excel.exe"
Shell sKill, vbHide

Upvotes: -1

ManoDestra
ManoDestra

Reputation: 6473

You need to call the Quit() method on your Excel.Application object (xlApp), https://msdn.microsoft.com/en-us/library/office/ff839269.aspx:

xlApp.Quit()

Upvotes: 2

Related Questions