-3
        Dim oXL As Object
        Dim oWB As Object
        Dim oSheet As Object
        ' Start Excel and get Application object.
        oXL = CreateObject("Excel.Application")
        oXL.Visible = True
        ' Get a new workbook.
        oWB = oXL.Workbooks.Add
        oSheet = oWB.ActiveSheet
        .........
        oXL.Quit()
        oWB = Nothing
        oXL = Nothing
        oSheet = Nothing

I can see the application opened in task manager ... Why ?

3 Answers3

0

You need to do what @Afnan Makhdoom said, but not only what he said you also need to call...

 GC.Collect()

This cleans up the objects being used and will remove it from task manager. Just releasing the objects won't remove it from task manager, you need to force the garbage collector.

Trevor
  • 7,777
  • 6
  • 31
  • 50
0

Try this so it will remove the task manager process after you open the excel file:

 Dim proc As System.Diagnostics.Process

        For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
            proc.Kill()
 Next
Waelhi
  • 315
  • 2
  • 7
  • 19
-1

What you need to do is release the objects first, it will surely exit the Excel.exe

oSheet.Close(False)
oXL.Quit()
releaseObject(oXL)
releaseObject(oWB)
releaseObject(oSheet)
oWB = Nothing
oXL = Nothing
oSheet = Nothing
Afnan Makhdoom
  • 654
  • 1
  • 8
  • 20
  • you can use GC.Collect but @MrCoDeXeR before saying "That won't work" be sure that you have the full understanding of someone's answer, it is not a good thing to criticize others, you posted your answer, good for you, don't budge in in other's answers, RESPECT OTHERS too! – Afnan Makhdoom Aug 07 '14 at 00:34
  • and for your information, it works -.- – Afnan Makhdoom Aug 07 '14 at 00:34
  • No it doesn't it won't be released from task manager without GC.Collect... here's a nice example of this you may find interesting fitting his exact issue... http://stackoverflow.com/questions/15697282/excel-application-not-quitting-after-calling-quit – Trevor Aug 07 '14 at 02:24
  • Also I mentioned you in the post, but I felt the need to criticize it. No feelings here, just constructive criticism. – Trevor Aug 07 '14 at 02:27
  • Wait, here's another one that I answered with the same issue... http://stackoverflow.com/questions/24595141/visual-basics-not-closing-excel/24596883#24596883 – Trevor Aug 07 '14 at 02:30
  • I'm sure I fully understand too, no need to remind me. – Trevor Aug 07 '14 at 02:31
  • Dude stick to your answer. Don't brother to comment here again. PS I checked my code and it is working perfectly fine – Afnan Makhdoom Aug 07 '14 at 09:18