How to open an excel file in read-only with actxserver?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kerstin John
el 18 de En. de 2021
Comentada: Marcelo
el 19 de En. de 2023
Hi,
I am using actxserver to read some data from various Excel files. The code works fine, but when it encounters a file that is currently opened by another user, it causes an error:
Error using Interface.000208D7_0000_0000_C000_000000000046/Item
Error: Call was rejected by callee.
When I open the same file manually in Excel, I get a dialog option to open it in read-only mode. Since I do not want to change or save the file, that is exactly what I need. Is there a way to choose this option from Matlab and avoid the error?
Thank you.
0 comentarios
Respuesta aceptada
Walter Roberson
el 18 de En. de 2021
https://www.mathworks.com/matlabcentral/answers/306813-problem-accessing-excel-files-through-xlsread
Which suggests
Excel.workbooks.Open(filename, 0, readOnly)
where Excel is the result of the activex call.
2 comentarios
Marcelo
el 19 de En. de 2023
Hi Walter
I took your suggestion and ran with it.
Excel.Workbooks.Open(fileName,0,0,1,'','',1);
Opens an "read-only suggested" Excel file with write access, skipping the nagging pop-up dialogue.
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!