I have a problem, where a network located shared Excel 2010 file is opened and being edited from VB.net successfully, but when I close it with Excel.Application.Quit(), the window itself closes, but an EXCEL.EXE process remains open.
As a workaround I kill the process if the Process.StartTime matches the time when I opened the excel, but this can a) not kill any excel process, which erroneously previously remained open b) could kill completely different workbooks...
Dim xlp() As Process = Process.GetProcessesByName("EXCEL")
For Each Process As Process In xlp
If Process.StartTime >= datestart And Process.StartTime <= dateEnd Then
Process.Kill()
End If
Next
I tried setting the sheet to saved, but it did not help. However if I unshare the excel table, then the process also dies properly when the workbook, and then the window is closed.
Dim xlApp As Excel.Application = Nothing
Dim xlWorkBook As Excel.Workbook = Nothing
Dim xlWorkSheet As Excel.Worksheet = Nothing
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Open(Excel_path)
xlWorkSheet = xlWorkBook.Worksheets(sheetName)
' whitchcraft here
xlWorkBook.Close(SaveChanges:=True)
xlApp.Quit()
releaseObject(xlWorkSheet)
releaseObject(xlWorkBook)
releaseObject(xlApp)
Please ease my misery...