I am creating an excel file using interop.excel and the process is not closing. This is the code i am trying to use.
Private Sub converToExcel(fileLoc As S
Finally solved :)
Private Function useSomeExcel(ByVal Excelfilename As String)
Dim objExcel As Excel.Application
Dim objWorkBook As Excel.Workbook
Dim objWorkSheets As Excel.Worksheet
Dim datestart As Date = Date.Now
objExcel = CreateObject("Excel.Application") 'This opens...
objWorkBook = objExcel.Workbooks.Open(Excelfilename) ' ... excel process
Dim dateEnd As Date = Date.Now
End_Excel_App(datestart, dateEnd) ' This closes excel proces
End Function
use this method
Private Sub End_Excel_App(datestart As Date, dateEnd As Date)
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()
Exit For
End If
Next
End Sub
This method closes especific process opened.
Try System.Runtime.InteropServices.Marshal.FinalReleaseComObject, that should help... also you should call xlWorkBook.Close() and xlapp.quit, if I recall correctly. First call them and then set them to nothing.