Select multiple range using Matlab Activex Server

I want to write the results of a data analysis with Matlab to an Excel spredsheet. To get it more handy and nice i also tried to format the content.
Because formating every single cell or range is very slow I tried to format a multiple range - but I didn't manage to get it running.
I recorded a macro directly with Excel that shows in principle, what i wanted to do:
Range("B355:AG359,B365:AG369").Select
Range("B365").Activate
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Color = -16776961
.TintAndShade = 0
.Weight = xlThin
End With
Now I tried to do it with Matlab ...
xls = actxserver('Excel.Application');
xlsDatei = xls.Workbooks.Open(xlsFileName);
myBook = xlsDatei.Sheets.Item(p);
myBook.Activate;
myRange = myBook.Range('B355:AG359,B365:AG369');
And this is the point - i always the following Matlab error:
Error using Interface.000208D8_0000_0000_C000_000000000046/Range
Error: Object returned error code: 0x800A03EC
Perhaps there who has done this before and can help me.

2 Comments

The error code appears to signify a range that is invalid or does not exist in the spreadsheet. Or trying to access beyond row 65535 in an xls file.
Yes, that's what I found by googeling an hour ...
Bur in this case, there must be an other reason.
I just tried the following code:
myBook.Range('B355:AG359')
myBook.Range('B365:AG369')
This works perfektly.
If I try to setup a multiple range
myBook.Range('B355:AG359,B365:AG369');
it returns with the following error message
Error using Interface.000208D8_0000_0000_C000_000000000046/Range
Error: Object returned error code: 0x800A03EC
So I think there should be no problem with my Excel file or the ActiveX Server.

Sign in to comment.

Answers (0)

Products

Release

R2018b

Asked:

on 16 Apr 2019

Commented:

on 16 Apr 2019

Community Treasure Hunt

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

Start Hunting!