account sign in window pops up when files are stored on onedrive using actxserver with Workbooks.Open

1 view (last 30 days)
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

Accepted Answer

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

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!