MATLAB: Are some long .NET statements are interpreted incorrectly in MATLAB 7.12 (R2011a)

errorlongMATLABnetshortstatement

When I make calls through the MATLAB .NET interface using long statements, I sometimes receive unexpected errors. For example when I try to use the Microsoft PowerPoint API in the following line:
newslide.Shapes.Title.TextFrame.TextRange.Text='.NET Powerpoint Demo';
This generates an error:
??? Setting the 'TextRange' property of the 'Microsoft.Office.Interop.PowerPoint.TextFrame' class is not allowed.
Sometimes it seems that the actual code has been executed as the objects in my .NET code have changed, even though an error occured.

Best Answer

This enhancement has been incorporated in Release 2012a (R2012a). For previous product releases, read below for any possible workarounds:
This is due to a limitation in MATLAB 7.12 (R2011a) in the way that long .NET statements are interpreted.
In order to work around this issue, split your longer statements into shorter ones. For example:
tr = newslide.Shapes.Title.TextFrame.TextRange;
tr.Text='.NET Powerpoint Demo';