How Can I Access Individual Powerpoint Shapes from a collection; actxserver COM objects
Show older comments
Hello All,
First time question asker!
I am trying to access multiple shapes (Title and Subtitle) one at a time in order to edit them in a PowerPoint presentation through the actxserver. However the collection of shapes does not seem to let me access the individual shapes - I have tried using indexing to access a specific shape but get the obvious index error below:
Index exceeds matrix dimensions.
I have read that accessing collections in MATLAB is a known issue, however I did not manage to find any solution - I am assuming it will involve the get command but I'm afraid I just haven't cracked it yet.
My code is as such:
%%Start an ActiveX session with PowerPoint:
ppt = actxserver('PowerPoint.Application');
ppt.Visible = 1;
pres = ppt.Presentations.Add;
% Apply Template
invoke(pres,'ApplyTemplate', template);
% Title Slide
title_slide = invoke(pres.Slides,'Add',1,1);
% This section works but only gives me access to the main title
title_shapes = get(title_slide.Shapes);
title = get(title_shapes.Title);
set(title.TextFrame.TextRange,'Text',main);
% When I try with the following line the error above is generated.
title_shape = get(title_slide.Shapes(1));
The rest of the code is not written (this is WIP) and the function is finished with the usual
% Quit PowerPoint
invoke(ppt,'Quit');
% End process
delete(ppt);
clear ppt pres;
The first slide invoked is a 'title' slide (containing title & subtitle). The template is simply a file with our company logo and not important. I am using MATLAB 2014a, and PowerPoint 2010.
If anyone can offer any advice/direction on how to access the shape it would be greatly appreciated!
Thanks, Andy
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!