필터 지우기
필터 지우기

Adding file in Excel with ActiveX and OLEObject

조회 수: 12 (최근 30일)
gdell0
gdell0 2021년 12월 17일
댓글: gdell0 2021년 12월 20일
Hello,
I have a question about Excel automation and OLEObject.
I have a code that generate a Excel report using ActiveX. My purpose is to insert a file (in my case .html) in a Excel worksheet so that the user can access it by cliking on the icon :
Here the code I tested (Matlab 2016b) :
e = actxserver('Excel.Application');
WB = e.Workbooks.Open(MyExcelFile);
eSheets = e.activeWorkbook.Sheets;
eSheetDatas = eSheets.get('Item', 1);
eSheetDatas.Activate
eSheetDatas.OLEObjects.Add([],MyHTMLFile,0,1,[],[],[],100,500,50,50); % For the options I want to fix a position, and show an icon
Close(WB)
Quit(e)
delete(e)
When I run this, Matlab get stuck like in infinite loop.
I think the syntax of the OLEObject.Add is not good for matlab.
Any help please ?
  댓글 수: 1
gdell0
gdell0 2021년 12월 20일
I did some more tests. In fact my code got stuck on the line :
Close(WB)
But only if I use add an OLE object before. I already used Close(WB) on another code with writing datas and changing forms and it worked well.
So I thouth about an issue while saving the xls file with the OLE object and tried this :
WB.Close(1, MyExcelFile)
But same behavior. Matlab get stuck on this line without closing the file.
If someone has an idea.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by