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

采纳的回答

Chris
Chris 2020-9-8
After I unticked file collaboration in the onedrive settings it works :)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by