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 view (last 30 days)
Show older comments
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
More Answers (0)
See Also
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!