When using Excel as an ActiveX server, why does the excel.exe process still exist after I close Excel?
Show older comments
When using Excel as an ActiveX server, I would like to know why the excel.exe process still exists after I close Excel.
I would like to know how the lingering Excel process that was created with actxserver can be terminated.
The following code uses ActiveX to open Excel, set values to a range, and close Excel. However, if I look under my Task Manager --> Processes, it still show that EXCEL.EXE exists. It is not taking any CPU time, but it is taking up memory.
Excel = actxserver('Excel.Application');
set(Excel, 'Visible', 1);
Workbooks = Excel.Workbooks;
Workbook = invoke(Workbooks, 'Add');
Sheets = Excel.ActiveWorkBook.Sheets;
sheet2 = get(Sheets, 'Item', 2);
invoke(sheet2, 'Activate');
Activesheet = Excel.Activesheet;
A = [1 2; 3 4];
ActivesheetRange = get(Activesheet,'Range','A1:B2');
set(ActivesheetRange, 'Value', A);
Range = get(Activesheet, 'Range', 'A1:B2');
B = Range.value;
B = reshape([B{:}], size(B));
invoke(Workbook, 'SaveAs', 'myfile.xls');
invoke(Excel, 'Quit');
Accepted Answer
More Answers (0)
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!