MATLAB: How to close an excel file

activexexcelshut down excel

Hellow everyone . i am using
winopen('myfile.xlsx')
to open an excel file , after doing some modification, i want to close the excel file in order to overwrite the existing data by
xlswrite('myfile.xlsx', my_modified_data )
but sometimes i forgot to close the file manually in between and MATLAB generates an error . Is there any way to automatically close the excel file(by some command like winclose or something like that) before writing into it . Thank You all .

Best Answer

Yes. You can use actxGetRunningServer() to connect to Excel and shut it down.