Excel file does not close in task manager
-
hi guys, The code below works fine except when i open the windows task manager, i can still see EXCEL.EXE Running. how do i close or exit it, should not objFso.Quit() Close Excel? thanks
Dim objFSO, ObjWb, ObjWs As New Object
objFSO = CreateObject("Excel.Application")
ObjWb = objFSO.Workbooks.Open("c:\myapp.xls")For Each ObjWs In ObjWb.Worksheets
MsgBox(ObjWs.Name)
Application.DoEvents()
NextobjFso.Quit()
-
hi guys, The code below works fine except when i open the windows task manager, i can still see EXCEL.EXE Running. how do i close or exit it, should not objFso.Quit() Close Excel? thanks
Dim objFSO, ObjWb, ObjWs As New Object
objFSO = CreateObject("Excel.Application")
ObjWb = objFSO.Workbooks.Open("c:\myapp.xls")For Each ObjWs In ObjWb.Worksheets
MsgBox(ObjWs.Name)
Application.DoEvents()
NextobjFso.Quit()
Since you have work books open, it would probably prevent Excel from closing.
-
Since you have work books open, it would probably prevent Excel from closing.
well this seems to work.... i have added this after the worksheets loop...
ObjWb.close()
releaseObject(ObjWs)
ObjWs = Nothing
releaseObject(ObjWb)
ObjWb = Nothing
releaseObject(objFSO)objFSO = Nothing Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical) End Try End Sub Private Sub releaseObject(ByVal obj As Object) Try System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) obj = Nothing Catch ex As Exception obj = Nothing Finally GC.Collect() End Try End Sub
-
hi guys, The code below works fine except when i open the windows task manager, i can still see EXCEL.EXE Running. how do i close or exit it, should not objFso.Quit() Close Excel? thanks
Dim objFSO, ObjWb, ObjWs As New Object
objFSO = CreateObject("Excel.Application")
ObjWb = objFSO.Workbooks.Open("c:\myapp.xls")For Each ObjWs In ObjWb.Worksheets
MsgBox(ObjWs.Name)
Application.DoEvents()
NextobjFso.Quit()
You also have to dispose the object
-
hi guys, The code below works fine except when i open the windows task manager, i can still see EXCEL.EXE Running. how do i close or exit it, should not objFso.Quit() Close Excel? thanks
Dim objFSO, ObjWb, ObjWs As New Object
objFSO = CreateObject("Excel.Application")
ObjWb = objFSO.Workbooks.Open("c:\myapp.xls")For Each ObjWs In ObjWb.Worksheets
MsgBox(ObjWs.Name)
Application.DoEvents()
NextobjFso.Quit()