Excel ComObject leaves excel.exe open after closing?
Posted: 08 Dec 2016, 09:30
Hi all,
I'm trying to work out how to close an excel comobject correctly without it leaving open a process in the background.
I cant use the get around of ending any process named excel.exe because I may have other copies of excel open at the time.
Could anyone take a look at the below and let me know if I'm closing the comobject incorrectly or something?
Many thanks!
I'm trying to work out how to close an excel comobject correctly without it leaving open a process in the background.
I cant use the get around of ending any process named excel.exe because I may have other copies of excel open at the time.
Could anyone take a look at the below and let me know if I'm closing the comobject incorrectly or something?
Many thanks!
Code: Select all
LRLocation := A_ScriptDir . "\" . "test" . ".xlsm"
xl := ComObjCreate("Excel.Application")
xl.Visible := true
path = %LRLocation%
xl.WorkBooks.Open(Path)
SaveLoc := A_MyDocuments . "\" . StockAccountCode . "- Price List.xlsx"
Xl.ActiveWorkBook.SaveAs(SaveLoc,51)
xl.quit
xl := ""