xlsread failed - Error registering event(s), Advise failed

5 ビュー (過去 30 日間)
Itachi
Itachi 2012 年 7 月 18 日
コメント済み: William Jones 2016 年 8 月 17 日
Hi guys, I get the following error when I'm trying to read from .xlsx files. please help me out.
Error registering event(s), Advise failed
Error in registerevent>addevent (line 148)
list(m+1) = handle.listener(h, eventname, {@comeventcallback, eventhandler});
Error in registerevent (line 94)
addevent(h, event, eventhandler);
Error in xlsreadCOM (line 11)
Excel.registerevent({'WorkbookActivate', @WorkbookActivateHandler});
Error in xlsread (line 230)
[numericData, textData, rawData, customOutput] = xlsreadCOM(file, sheet, range,
Excel, customFun);
  1 件のコメント
Samer Husam
Samer Husam 2012 年 7 月 18 日
can you list down your code ?

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

回答 (2 件)

Image Analyst
Image Analyst 2012 年 7 月 18 日
Are you using an old version of MATLAB before xlsx files were around? What release do you have (the R number)? Also you need to have Excel installed to use xlsread and xlswrite - MATLAB can't read and write the files by itself. What version of Excel do you have installed?
  2 件のコメント
Itachi
Itachi 2012 年 9 月 8 日
I'm using MATLAB R2012a and Excel 2010. I know that it's because MATLAB open and closes Excel every time that I use these functions. But it should not happen. I've used xlsread1 and xlswrite1 from fileexchange section and it got OK.
Image Analyst
Image Analyst 2012 年 9 月 8 日
If you're using xlsread() and you already have a file open, particularly the file you're trying to open with xlsread() you'll probably get an error. Make sure Excel is closed before you call xlsread(). You might try typing control-shift-Esc to bring up the process list (in Windows) and see if perhaps Excel is a running process even though you don't see it anywhere visible on your desktop or taskbar.

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


Ron Lu
Ron Lu 2013 年 4 月 10 日
編集済み: Ron Lu 2013 年 4 月 10 日
I have the same problem as yours, Win7 with Matlab 2012a and Excel 2010. My solution is to kill all excel processes if they are not closed properly after xlsread.
Put this code after xlsread funcion call solved my problem:
[~, computer] = system('hostname');
[~, user] = system('whoami');
[~, alltask] = system(['tasklist /S ', computer, ' /U ', user]);
excelPID = regexp(alltask, 'EXCEL.EXE\s*(\d+)\s', 'tokens');
for i = 1 : length(excelPID)
killPID = cell2mat(excelPID{i});
system(['taskkill /f /pid ', killPID]);
end
  1 件のコメント
William Jones
William Jones 2016 年 8 月 17 日
This is amazing, I would've never solved this problem for my excelread function. Do you have the time to explain what it does?

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

カテゴリ

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