I only have this problem when accessing files within my onedrive folder. I aldreay deactivated files on demand.
account sign in window pops up when files are stored on onedrive using actxserver with Workbooks.Open
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I am running the below code to delete emtpy sheets with MATLAB 2020a and Excel 2016. When doing so Excel asks me to sign into my account. Is there away to do this automatically?
excelFileName = [file_name,'.xlsx'];
sheetName = 'Sheet'; % EN: Sheet, DE: Tabelle, etc. (Lang. dependent)
% Open Excel file.
objExcel = actxserver('Excel.Application');
objExcel.Workbooks.Open(fullfile(excelFilePath, excelFileName)); % Full path is necessary!
% Delete sheets.
try
% Throws an error if the sheets do not exist.
objExcel.ActiveWorkbook.Worksheets.Item([sheetName '1']).Delete;
objExcel.ActiveWorkbook.Worksheets.Item([sheetName '2']).Delete;
objExcel.ActiveWorkbook.Worksheets.Item([sheetName '3']).Delete;
catch
; % Do nothing.
end
% Save, close and clean up.
objExcel.ActiveWorkbook.Save;
objExcel.ActiveWorkbook.Close;
objExcel.Quit;
objExcel.delete;
I only have this problem one specifc pc. On all other PCs its fine. The Excel Add-in for matlab is also active in excel.
Thanks for the help!
Chris
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!