Unable to save excel spreadsheet without being prompted to replace original file

9 ビュー (過去 30 日間)
Bolin
Bolin 2013 年 9 月 29 日
コメント済み: Shar 2017 年 1 月 19 日
Note: This probably has nothing to do with xlsread and xlswrite
My current matlab program attempts to clear a spreadsheet as follows:
Excel = actxserver('Excel.Application');
File = Excel.workbooks.open(path);
%clear the designated range from the designated worksheet
file.worksheets.item(worksheet).range('A:A').clearcontents
invoke(file,'save')
invoke(file,'close')
invoke(Excel, 'quit')
The program runs flawlessly (no syntax errors), but nothing is performed.
The problem I am facing are: 1. Excel will prompt me whether to replace the existing file or not, I want to replace the existing file but I can't just have someone sit around to click yes or no on a 10 hour program 2. The file becomes read only, the file was not read only to begin with (and I made sure of that) 3. Nothing has been cleared
The problem here is the function invoke, I have no idea what it is doing. Is there another way of performing what I am requesting my matlab to do?

回答 (1 件)

Image Analyst
Image Analyst 2013 年 9 月 29 日
You need to turn off alerts:
Excel = actxserver('Excel.Application');
Excel.DisplayAlerts = false; % Suppress Excel warning popups, like for overwriting a file.
  2 件のコメント
vcmorini
vcmorini 2016 年 11 月 15 日
Thank you. Worked nicely.
Shar
Shar 2017 年 1 月 19 日
Hi, how can I do not overwrite the excel file? I want to save several pics to an excel file without overwriting it!

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

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by