View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Smart PowerPoint Exporter

4.9 | 18 ratings Rate this file 57 Downloads (last 30 days) File Size: 19.1 KB File ID: #30124 Version: 1.7
image thumbnail

Smart PowerPoint Exporter


Dmitriy Aronov (view profile)


21 Jan 2011 (Updated )

Exports Matlab figures to PowerPoint. Fixes formatting directly in PowerPoint to allow easy editing.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

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.


Saveppt inspired this file.

This file inspired Colormouse.

MATLAB release MATLAB 7.10 (R2010a)
Other requirements - Windows - Tested in Microsoft PowerPoint 2010
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
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

Comment only
12 Jun 2015 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,


Comment only
12 Jun 2015 Jens Richter

Jens Richter (view profile)

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.


Comment only
01 Jun 2015 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,

Comment only
08 Apr 2015 Procyon

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.

Comment only
26 Mar 2015 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, ...

Comment only
23 Jun 2014 Cris

Cris (view profile)

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,

Comment only
19 Jun 2014 Laurel

Laurel (view profile)

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.

Comment only
19 Jun 2014 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');

Comment only
10 Jun 2014 Laurel

Laurel (view profile)

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.

Comment only
24 Apr 2014 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

Comment only
21 Apr 2014 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.

22 Nov 2013 Jens Richter

Jens Richter (view profile)


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 ;-)


22 Nov 2013 Alex Tayler

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

17 Oct 2013 Frederic

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

Comment only
12 Sep 2013 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!

29 Jul 2013 Scott Otterson

Very useful!

29 Jun 2013 Nevzus

Nevzus (view profile)

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

Comment only
22 Apr 2013 Diego

Diego (view profile)


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"

Comment only
27 Feb 2013 Darik

Darik (view profile)

03 Oct 2012 Renwen Lin

05 Sep 2012 Matt Caywood

Matt Caywood (view profile)

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.

05 Sep 2012 Matt Caywood

Matt Caywood (view profile)

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');

Comment only
27 Jul 2012 Daniel

Daniel (view profile)

27 Jul 2012 Daniel

Daniel (view profile)

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

31 May 2012 claire

claire (view profile)

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

Comment only
18 May 2012 Daniel Helmick

Daniel Helmick (view profile)

  • 1 file
  • 4.15789

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.

04 May 2012 Joachim

25 Apr 2012 Darren

Darren (view profile)

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?

07 Feb 2012 Benjamin

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'.

02 Feb 2012 Guy

Guy (view profile)

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

28 Dec 2011 Hugh

Hugh (view profile)

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

Comment only
25 Oct 2011 Tim

Tim (view profile)

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.


06 Oct 2011 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.

Comment only
23 Sep 2011 Doug Harriman

16 Sep 2011 Boris

Boris (view profile)

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.

Comment only
08 Sep 2011 Yuri K

Yuri K (view profile)

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.

Comment only
26 Aug 2011 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.


Comment only
28 Jul 2011 Etienne

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?

Comment only
04 May 2011 Cristina

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 :) :) :)

10 Feb 2011 1.2

Improved speed, better documentation, fixed TEX exporting bug, added some optional exporting properties.

10 Feb 2011 1.4

Corrected documentation/acknowledgement typos

11 Feb 2011 1.5

Fixed minor bug during scientific axis exporting

18 Feb 2011 1.7

- Added options for exporting figure/axis background colors - Added bitmap exporting option - Added image resolution properties - Added full support for TEX formatting - Corrected minor bugs

Contact us