How to open an excel file in read-only with actxserver?

41 ビュー (過去 30 日間)
Kerstin John
Kerstin John 2021 年 1 月 18 日
コメント済み: Marcelo 2023 年 1 月 19 日
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.

採用された回答

Walter Roberson
Walter Roberson 2021 年 1 月 18 日
  2 件のコメント
Kerstin John
Kerstin John 2021 年 1 月 18 日
Thank you very much for the quick answer. It is working, although I have not been able to reproduce the initial error. But this solves my problem.
Marcelo
Marcelo 2023 年 1 月 19 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeUse COM Objects in MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by