Copying, pasting, and editing figures from MATLAB programatically

4 visualizzazioni (ultimi 30 giorni)
Previously, using Matlab 2015a and PowerPoint 2010, I would paste a jpg (copied from plot window) into a new slide and modify the position and width of the picture using the following code. Now that I've upgraded to Office 2013, I get an error when trying to set any "pic" properties (Error using Interface.Microsoft_PowerPoint_15.0_Object_Library.ShapeRange/set; Error: Object returned error code: 0x800A01A8). What changed in the new Office? How do I fix this? When I try to get properties of "pic", "Error 0x800A01A8" is displayed under all property fields.
ppt = actxserver('PowerPoint.Application');
op = invoke(ppt.Presentations,'Add');
slide_count = get(op.Slides,'Count');
template = 'template.potx';
a = ppt.ActivePresentation;
invoke(a,'ApplyTemplate',template);
for n=1:length(nfigs);
% Add a new slide (with title object):
slide_count = int32(double(slide_count)+1);
layout = ppt.ActivePresentation.SlideMaster.CustomLayouts.Item(10);
new_slide=ppt.ActivePresentation.Slides.AddSlide(n, layout);
% Get height and width of slide:
slide_H = op.PageSetup.SlideHeight;
slide_W = op.PageSetup.SlideWidth;
% Insert text into the title object:
titletext = get(figure(nfigs(n)),'name');
set(new_slide.Shapes.Title.TextFrame.TextRange,'Text',titletext);
set(new_slide.HeadersFooters.Footer,'Visible',true)
set(new_slide.HeadersFooters.Footer,'Text','| Document Name | Enter Date')
set(new_slide.HeadersFooters.SlideNumber,'Visible',true)
set(nfigs(n),'units','normalized','outerposition',[0 0 1 1]);
% Copy figure(s) as bitmap(-dbitmap) (use '-dmeta' to copy as meta file instead)
options.Format = 'jpg';
hgexport(gcf,'-clipboard', options);
pic = invoke(new_slide.Shapes,'Paste');
% Set picture to width of slide, justify left, and 90% from the top, then close figure
set(pic,'Width',720);
set(pic,'Left',(slide_W-get(pic,'Width'))/2)
set(pic,'Top',slide_H-slide_H*.905);
set(nfigs(n),'units','normalized','outerposition',[0.3 0.6 0.3 .4]);
%close(gcf)
end

Risposte (0)

Categorie

Scopri di più su MATLAB Report Generator in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by