Matlab Excel COM API using actxserver causing "Invoke Error, Dispatch Exception: Type mismatch."

5 views (last 30 days)
Hello. I am trying to put a matrix of 605601 x 1055 double into excel using the COM API using this line:
eSh.Range('A9:ANO605609').Value = t;
where, eSh is the Excel Workbook Activesheet, and t is the matrix I'm trying to put into Excel.
However, the command above give me the error: "Invoke Error, Dispatch Exception: Type mismatch."
any comments or suggestions are appreciated.
Thanks.

Answers (1)

Sangeetha Jayaprakash
Sangeetha Jayaprakash on 1 Nov 2016
You seem to be encountering this error when you are trying to write data to an Excel file using "actxserver" from MATLAB. Some possible scenarios in which this error can occur are:
  1. This error may occur if a file with macros is saved in Excel 2003 and then used with Excel 2007 or Excel 2010. If this is the case, try opening the file with Excel 2007 or 2010 and re-saving it.
  2. This could be due to a limitation on the amount of data you can pass through the COM object to Excel.As a workaround you can try to write data into Excel in blocks until all of the data has been written to the file.
  1 Comment
Quy Phan
Quy Phan on 1 Nov 2016
It seems the error is from the matrix being too large. I tried writing in blocks and it works. Any idea what the limit is to write in Excel using the COM API?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!