How do I pass a string array to the PowerPoint object Range method in MATLAB 7.0.4 (R14SP2)?

5 views (last 30 days)
I have created a COM object with a Range method. This method accepts a variant and returns a collection of objects.
ppt_app=actxserver('powerpoint.application')
ppt_app.Visible=1
ppt_presentation=ppt_app.Presentations.Add
ppt_slide=ppt_presentation.Slides.Add(1,'ppLayoutTitleOnly')
figure
plot(1:6,sin(2*pi*4*[1:6]))
print -dmeta -noui
ppt_figure1=ppt_slide.Shapes.Paste
t=1:100;
y=sin(2*pi*.1*t);
plot(t,y)
print -dmeta -noui
ppt_figure2=ppt_slide.Shapes.Paste
shapes=ppt_slide.Shapes
When I try to pass more than one string argument as follows
shapes.Range({'Picture 3'; 'Picture 4'})
I receive the following error
??? Invoke Error, Dispatch Exception:
Source: Microsoft Office PowerPoint 2003
Description: Shapes.Range : Illegal value for ^0. Bad type: expected 1D array of Variants, Integers, Longs, or Strings
Help File:
Help Context ID: 0

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The object method Range only accepts one-dimensional arrays. However, MATLAB by default creates two-dimensional arrays.
To work around this, apply the following prior to calling the Range method;
system_dependent('COM_SafeArraySingleDim', 1)
This forces MATLAB to export single dimension arrays instead of two-dimensional when exporting arrays to COM objects. Note that the cell array
{'Picture 3'; 'Picture 4'}
elements must separated by a semicolon (";") rather than a comma (",") or a space.

More Answers (0)

Categories

Find more on Data Type Identification in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R14SP2

Community Treasure Hunt

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

Start Hunting!