The following code works, but the excel.exe process still runs, even if I exit Excel. I am using Office 2013 and reference the correct import of Office.Interop.Excel
What did I miss
Sub demo()
Dim xls As New Excel.Application
Dim book As Excel.Workbook
Dim oSheet As Excel.Worksheet
xls.Workbooks.Open("Test.xlsx")
book = xls.ActiveWorkbook
oSheet = book.ActiveSheet
oSheet .Cells(1, 2).Value = "testing"
book.Save()
book.Close()
xls.Workbooks.Close()
xls.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(book)
System.Runtime.InteropServices .Marshal.ReleaseComObject(xls)
oSheet = Nothing
book = Nothing
xls = Nothing
GC.Collect()
End Sub
If you still have problems, are you trying to kill the process?
Process[] procs = Process.GetProcessesByName("name");
foreach (Process proc in procs)
proc.Kill( );
Don’t know if it will work the way you want, but this is an idea.
The code below works, but excel The .exe process still runs, even if I quit Excel. I am using Office 2013 and refer to the correct import of Office.Interop.Excel
What am I missing
Sub demo()
Dim xls As New Excel.Application
Dim book As Excel.Workbook
Dim oSheet As Excel.Worksheet
xls.Workbooks.Open(" Test.xlsx")
book = xls.ActiveWorkbook
oSheet = book.ActiveSheet
oSheet.Cells(1, 2).Value = "testing"
< br /> book.Save()
book.Close()
xls.Workbooks.Close()
xls.Quit()
System.Runtime.InteropServices .Marshal.ReleaseComObject(oSheet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(book)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xls)
oSheet = Nothing
book = Nothing
xls = Nothing
GC.Collect()
End Sub
If you still have problems, are you trying to kill the process?
Process[] procs = Process.GetProcessesByName("name");
foreach (Process proc in procs)
proc.Kill( );
I don’t know if it will work the way you want, but this is an idea.