How to close any file without saving it?
20 次查看(过去 30 天)
显示 更早的评论
Hello, I want to know what is the command for closing a particular type of file without any requist to save it.
i.e. I want to know:
- How can I close all files from any type of application e.g. close all txt files that are open?
- How can I close those files automatically without saving?
I already know, for closing an excel file the following commands are used:
However when I use code, the application, (in this case excel) asks me if I want to save my file.
try
Excel = actxGetRunningServer('Excel.Application');
Excel.Quit; % Shut down Excel.
catch
end
0 个评论
回答(1 个)
Chunru
2021-8-13
Is "fclose all" what you want?
4 个评论
Chunru
2021-8-13
编辑:Chunru
2021-8-13
Excel = actxGetRunningServer('Excel.Application') will run the external exel server. You can check https://docs.microsoft.com/en-us/office/vba/api/overview/excel to see how the external server Quit the file without confirmation.
Try the follwing to see if you can skip the confirmation.
Excel = actxGetRunningServer('Excel.Application');
Excel.DisplayAlerts = false;
Excel.Quit
On the other hand, if you can replace the actx and use xlswrite, then you will not have the problem of confirming quit.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!