File Exchange

image thumbnail

Smart PowerPoint Exporter

version (19.1 KB) by Dmitriy Aronov
Exports Matlab figures to PowerPoint. Fixes formatting directly in PowerPoint to allow easy editing.


Updated 18 Feb 2011

View Version History

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

This program exports a Matlab figure to PowerPoint and converts it into a group of PowerPoint objects. It then edits various object properties directly in PowerPoint, such that the figure can be easily modified without disrupting appearance, alignment, etc.

Program features:
(See Screenshot for summary)

- Exports using an added button on the Matlab toolbar or using command line code.

- Applies proper alignment and anchoring to all axis labels, tick labels and text boxes, such that they don't become misaligned following figure resizing or font changes in PowerPoint.

- Identifies logarithmic and scientific notation axes and applies superscripts in PowerPoint. This prevents the splitting of each superscripted label into two text boxes, which occurs during standard copy-pasting into PowerPoint.

- Converts each TEX-formatted textbox into a single properly formatted PowerPoint textbox. This prevents the splitting of TEX boxes into multiple objects. Converts all special TEX characters to Unicode.

- Removes unnecessary background color/outline objects that result from standard copy-pasting and instead edits these PowerPoint features directly.

- Combines pieces of each trace into a single PowerPoint group object to allow easy editing.

- Allows exporting object-dense parts of the figure as bitmaps, while leaving other parts in editable metafile format.

- Allows specifying the image resolution of both metafile and bitmap figure parts.

- Allows specifying the PowerPoint slide to which the figure is exported.

- Allows specifying the size and position of the exported figure.

- Allows grouping objects for speed and bulk-editing in PowerPoint.

Cite As

Dmitriy Aronov (2021). Smart PowerPoint Exporter (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (40)


Can any one please post an example how to use this function? i am having a hard time figuring it out

Laurent Couturier

Hi Jens,

I now use your function toPPT(numfig,'format','vec') instead of pptfigure(numfig) for the same result!
Thanks a lot Jens,


Jens Richter

Hi Laurent,

it worked for me when I just did a "try catch" what is actually ignoring this line. But I have to commit I changed a lot of the code in general. If you are interested you can check my toPPT that is using "Smart PowerPoint Exporter" functionality in addtion to other features becuase I think Smart PowerPoint Exporter is not really maintained anymore :-( . E.g. you can just extract the part that you are interested in from toPPT.


Laurent Couturier

Hi, I have also problems in using this great function with Matlab14b and Power Point 2013. I modify the function according to the suggestion of Cris but another error arose:
Error using Interface.9149347A_5A91_11CF_8700_00AA0060263B/set
Error: Object returned error code: 0x800A01A8

Error in pptfigure (line 911)
set(pic,'Left',0,'Top',0, ...
Does someone have a suggestion to fix it? Thank you in advance,


Hello Jian Sun, I had a similar error (though I'm not using Mac but I don't think that matters). I got that error on line 560 which issues a similar call: num2str(H).

H is the handle to the figure which contains many properties. As of Matlab 2014b, the graphics handle is no longer of type 'double', it is not an object. According to Mathworks documentation (, you can no longer "[Convert] handles to strings or use handles in string operations".

Perhaps every instance of num2str(H) should be replaced by num2str(H.Number). This includes Line 67 and line 560 (there are others).

After making that change though, I'm on to new errors:

Error using Interface.9149347A_5A91_11CF_8700_00AA0060263B/get
Error: Object returned error code: 0x800A01A8

Error in pptfigure (line 564)
metaWidth = get(pic,'Width');

When I view the 'pic' object with get(pic), most of the properties report errors.

Jian Sun

Hi, I have trouble to use it. I am using it in R2014b in macbook pro. The export button was not generated for me. The error message I got is below, any thoughts?
Undefined function 'abs' for input arguments of type 'matlab.ui.Figure'.

Error in num2str (line 66)
xmax = double(max(abs(widthCopy(:))));

Error in pptfigure (line 67)
uipushtool(toolbar,'CData',get_ppt_image, ...


I just found this nice workaround Eric Sampson posted in the comments to 'saveppt2' to work flawlessly with 'pptfigure' and PowerPoint 2013 as well.

Here follows his orginal comment:


Hi all, for those of you who are encountering an error when using this function with PowerPoint 2013, to correct this issue you can replace the following line:
pic1 = invoke(new_slide.Shapes,'Paste');

with the following two lines:

picShapeRange = invoke(new_slide.Shapes,'Paste');
pic1 = invoke(picShapeRange,'Item',1);

This fix will still work when using older versions of PowerPoint.


Everything I did was to modify it as follows and everything worked as before:

picShapeRange = invoke(new_slide.Shapes,'Paste'); % or: picShapeRange = invoke(slide.Shapes,'PasteSpecial', 3); (as required)
pic = invoke(picShapeRange,'Item',1);

Best regards,


Not yet... I can only get this working by having a 2007 Powerpoint open, then converting the slide to PowerPoint 2013. It's not exactly elegant but it does work. The issue seems to be the call to actxserver is designed to work with an older version of ppt.

Yair Churi

Laurel, its seems like I am seeing the same failure. Were you able to resolve this?

Error using Interface.9149347A_5A91_11CF_8700_00AA0060263B/get
Error: Object returned error code: 0x800A01A8

Error in pptfigure (line 564)
metaWidth = get(pic,'Width');


I am having the same issue as Diego.
I am running Matlab R2014a on a Windows 7 OS, trying to interact with Powerpoint 2013.
I get the following error:

Error using Interface.Microsoft_PowerPoint_12.0_Object_Library.ShapeRange/get
Error: Object returned error code: 0x800A01A8

Error in pptfigure (line 564)
metaWidth = get(pic,'Width');

Error while evaluating uipushtool ClickedCallback

Does anyone know what changed with the newer PPT versions? I would really like to use this function.

Julian Hapke

I think the feature('COM_SafeArraySingleDim', 1)
should be reset to 0 when the function is done, so matlabs default behavior is restored

Carl Witthoft

Perhaps should include a warning that plots will be dumped to the currently open PPT document :-) . Love the option to execute from the command line (rather than via button), thus allowing automated scripting of multiple plots.
Also very handy, but hidden in the html doc page: ability to place new PPT page at current location in (an open) PPT doc, rather than appending to the existing slide set.

Jens Richter


I recently discovered this nice script, what is unfortunately not complety up to date in terms of compatibility and indeed sometimes pretty hard to use.
Anyway great work. I also was facing different problems. Most of them could be solved with the help of this thread and belive it or not with the fu**ing manual :-D

I also where able to "understand and work arround" one problem that some of you mentioned:

??? Invoke Error, Dispatch Exception:
Source: Microsoft PowerPoint 2010
Description: ShapeRange.Item : Integer out of range. 2 is not in Index's valid range of 1 to 1.
Help File:
Help Context ID: 0

It seems that this most likely happens when the number of points in your plot is to high. This happened to me when I used pcolor with a big amount of data points.
A work arround is simply to export this graph as image via (lets assume it's figure1):


% 200 indicates the resolution

You also can use other properties for 'BitmapResolution' => Have a look into the manual ;-)


Alex Tayler

Frederic, it's unsatisfying but if you simply comment out line 961 the program works with newer version of powerpoint.


I used pptfigure to copy figures and it worked pretty well. But for some weeks it appears that it doesn't work anymore and I get the following error message:

Error using Interface.9149347F_5A91_11CF_8700_00AA0060263B/set
Invoke Error, Dispatch Exception: Erreur non spécifiée

Error in pptfigure (line 961)
Does anyone have an idee on how to fix this problem?
Thank you in advance

Rhymer Yang

I used to copy figure to PowerPoint, ungroup it, edit objects and group them again; very tedious. This function does all these automatically! It's AWESOME! Works like a charm! Thanks for the great work!

Scott Otterson

Very useful!


I am looking for this kind of application everywhere but cannot find a version that works for Mac. Can this be made to work for Mac as well?
Thanks, - NG



Im using matalb 2012b and powerpoint 2013. I try to use this but I get

"Error using Interface.9149347A_5A91_11CF_8700_00AA0060263B/get
Error: Object returned error code: 0x800A01A8

Error in pptfigure (line 564)
metaWidth = get(pic,'Width');

Error while evaluating uipushtool ClickedCallback"


Renwen Lin

Matt Caywood

Overall this function is good but is very finicky. It's the best way I've found to get vector graphics out of Matlab, but it's not for beginners.

My admiration to the author for digging into the swamp of Matlab graphics, which even Mathworks is afraid to touch.

Matt Caywood

If my figure is wider than *exactly* 1253 pixels, pptfigure will not copy it to Powerpoint (2010) correctly -- it will leave a stray garbage "coded" axis to the upper left of the slide.

This axis is created by
line 561: pic = invoke(slide.Shapes,'PasteSpecial',3);

and supposed to be destroyed (but not fully destroyed) by line 601: invoke(pic,'Delete');



Just got this and absolutely amazed. It makes the plots from Matlab look so clean in PowerPoint. An absolute Must!


It works great, except it doesn't preserve the transparency setting of the "fill" on my graph. Any idea how I can add that?

Daniel Helmick

Works great in most situations. I really love this.

Also doesn't capture the plot correctly if lines are turned off during the copying process.



This is a fantastic file. However, I run into trouble trying to export text with the sprintf function. It ends up omitting the text. Thoughts?


As of Feb 2012, pptfigure does not seem to properly export colorbars to Power Point. I made two changes to the code to make colorbars work (at lines 874 & 1109):
@@ -874,6 +874,18 @@
if ~isempty(find(legends==objects(obj),1))
+ if strcmp(get(objects(obj),'Tag'), 'TMW_COLORBAR')
+ % For colorbars, parent axes need to be visible.
+ set(get(objects(obj), 'parent'),'visible','on');
+ % Make colorbar ticks temporarily invisible by clearing their
+ % text, but keep colorbar axis labels in same positions.
+ ytick = get(get(objects(obj), 'parent'),'ytick');
+ cbar_lbl = findobj(objects, 'Type','text', ...
+ 'Parent',get(objects(obj),'Parent'));
+ cbar_lbl_pos = get(cbar_lbl,'Position');
+ set(get(objects(obj), 'parent'),'ytick',[]);
+ set(cbar_lbl,{'Position'},cbar_lbl_pos);
+ end
set(objects(find(invisible)),'visible','off'); %#ok<FNDSB>

% Set axis positions to original values
@@ -1109,6 +1121,10 @@
if strcmp(type,'text')
+ if strcmp(get(objects(obj),'Tag'), 'TMW_COLORBAR')
+ % Restore YTick values to colorbar axes
+ set(get(objects(obj), 'parent'),'ytick',ytick);
+ end

The problem is that the image containted within the colorbar axes does not display when its 'Visibile' property is set to 'on'.


Similar to Hugh's problem, If I already have PowerPoint open, it works great. If not, if I try to use this from either the command line or the figure button I get the following error:

??? Invoke Error, Dispatch Exception:
Source: Microsoft Office PowerPoint 2007
Description: Application.ActiveWindow : Invalid request. There is no currently
active document window.
Help File:
Help Context ID: 0

Error in ==> pptfigure at 343
wind = get(ppt,'ActiveWindow');

??? Error while evaluating uipushtool ClickedCallback


Hi, I typed "pptfigure", nothing happended. What did I do wrong?


Excellent program!

I initially had problems with the legend in the PowerPoint slide. For some reason if the symbol was a circle ('o') or square ('s'), it was removed. If I changed the symbols to something other than circles or squares, it seemed to be okay. As a temporary fix, I commented out line 939, and all symbols made it.

938 if isempty(deblank(txt)) returns 939 %invoke(pic.Item(c),'Delete');

If you have a better fix, please let me know.


Sander Aerts

I have the same problem as Boris. When i run the following:
>> clear all, close all
>> [~]=peaks;view(2);
>> pptfigure(1);
??? Invoke Error, Dispatch Exception:
Source: Microsoft PowerPoint 2010
Description: ShapeRange.Item : Integer out of range. 2 is not in Index's valid range of 1 to 1.
Help File:
Help Context ID: 0

Error in ==> pptfigure at 926

Basically the same error but then with powerpoint 2010. It does however create a slide but the created object somehow appears to be totally blank.
If it worked properly I would certainly use this tool.

Doug Harriman


I tried this with PowerPoint 2010 SP1 on Windows XP SP3, using Matlab 2010a. The button appears, and when you click it, it opens PowerPoint, but then just generates a blank slide... No errors are given but it appears not to work (unfortunately)... I was trying to export a mixed area and line plot.

Yuri K

I was very excited about this function. But does it work with PowerPoint 2007? Not working for me. MATLAB 2011a.
pptfigure does not open figure and returns no error. If I create the figure myself then:
>> pptfigure(gcf)
??? Invoke Error, Dispatch Exception:
Source: Microsoft Office PowerPoint 2007
Description: ShapeRange.Item : Integer out of range. 2 is not in Index's valid range of 1 to 1.

Federico Miorelli

Great idea and incredibly easy to use!
I have an issue with some types of plot though: for example if I plot any matrix with pcolor I get an error when exporting.



Hi Dmitriy

My axes title labels are duplicated several times. I checked in the original, but there is only one instance. Have you seen this problem before?


This exporter is awesome. You won't have to regenerate matlab figures to make them legible, rescale subplots, change distances between functions, change colors, font size, add or remove tick marks to the axes, remove parts of your plot that you don't want on your slides etc. It takes most of the pain out of working with matlab figures :) thank you :) :) :)

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: saveppt

Inspired: Colormouse

Community Treasure Hunt

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

Start Hunting!