Here is a code for a button on form1:
Dim Xl As New Excel.Application()
Dim Xlb As Excel.Workbook = Xl.Workbooks.Open("C:\Kk.xls")
Dim Xls As Excel.Worksheet = CType(Xlb.Worksheets(1), Excel.Worksheet)
TextBox1.Text = Xls.Cells(1, 1).value
Xls.Cells(1, 1).Value = "Something new"
Xlb.Save()
Xlb.Close()
Xl.Workbooks.Close()
Xl.Quit()
When I click that, everything works as planned, but EXCEL.EXE is still a running process. The result is that you can not open Kk.xls through excel until my program is ended entirely. The problem with this is if my program crashes or ends by any other method other than the END command, Excel is still running and keeping that file in use. How do I completely shut down Excel after running the above code?
Dim Xl As New Excel.Application()
Dim Xlb As Excel.Workbook = Xl.Workbooks.Open("C:\Kk.xls")
Dim Xls As Excel.Worksheet = CType(Xlb.Worksheets(1), Excel.Worksheet)
TextBox1.Text = Xls.Cells(1, 1).value
Xls.Cells(1, 1).Value = "Something new"
Xlb.Save()
Xlb.Close()
Xl.Workbooks.Close()
Xl.Quit()
When I click that, everything works as planned, but EXCEL.EXE is still a running process. The result is that you can not open Kk.xls through excel until my program is ended entirely. The problem with this is if my program crashes or ends by any other method other than the END command, Excel is still running and keeping that file in use. How do I completely shut down Excel after running the above code?