필터 지우기
필터 지우기

Why does activate excel sheet 2 via ACTXSERVER return an error ?

조회 수: 2 (최근 30일)
Meng Li Gan
Meng Li Gan 2019년 1월 21일
댓글: Walter Roberson 2019년 11월 7일
I am trying to activate sheet 2 of excel by using actserver, but it will return an error when I run my code. Can anyone explain what I had did wrong for my code?
your explaination will be greatly appreciated. My code is as below
e= actxserver('excel.application');
% Insert a new workbook.
eWorkbook = e.Workbooks.Add;
e.Visible = 1;
% Make the sheet active.
eSheets = e.ActiveWorkbook.Sheets;
eSheet1 = eSheets.get('Item', 2); % Want to edit 2nd sheet in workbook
eSheet1.Activate;
% Below is the error shown
% Error using Interface.Microsoft_Excel_16.0_Object_Library.Sheets/get
% Invoke Error, Dispatch Exception: Invalid index.
Besides, i am trying to write a set of data to excel with my own layout (merged cell, border line, colomn color), can I know where can I get the example or tutorial to use actxserver to write data to excel? Thanks in advance.
Regards, Lily
  댓글 수: 2
Henry Barth
Henry Barth 2019년 11월 7일
This is an interesting question :-)
Walter Roberson
Walter Roberson 2019년 11월 7일
At the moment as outside observers, we do not know that the workbook has more than 1 sheet after the Add is done.

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

답변 (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