Get from Ico-github-logo

Highlights from

  • exportToPPTX.m
  • examples_exportToPPTX.m
    % Example usage of exportToPPTX
  • View all files
4.9 | 25 ratings Rate this file 116 Downloads (last 30 days) File Size: 719 KB File ID: #40277
image thumbnail




12 Feb 2013 (Updated )

MatLab tool for exporting data to PowerPoint 2007+ files without using COM-objects automation

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

exportToPPTX allows user to create PowerPoint 2007+ (PPTX) files without using COM-objects automation (or PowerPoint application itself). exportToPPTX writes PPTX files natively.
Note about PowerPoint 2003 and older: To open these PPTX files in older PowerPoint software you will need to get a free office compatibility pack from Microsoft:

Basic command syntax:


List of available commands:
* new - start new file
* open - open (to append to) existing file
* addslide - add new slide
* addnote - add slide notation
* addpicture - add image (figure handle, CDATA, image filename) to current slide
* addtext - add textbox to current slide
* save - save file
* close - close (clear temporary file)
* query - get information about current status

Examples of all of these commands and various options are in the examples_exportToPPTX.m file.

Up-to-date version, a more detailed help, bugs/issues tracking can all be found here:


This file inspired To Ppt.

Required Products MATLAB
MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (41)
23 Jan 2015 Ivan

Ivan (view profile)

Great! All works perfectly!

23 Jan 2015 Ivan

Ivan (view profile)

Really very very nice. However the default size appears to be 10x8 and not 10x7.5 and it is impossible to create any other size. It looks like the ('new',[11.7 8.27]) is ignored (MATLAB 2014b, MS Office 2013)

20 Nov 2014 Esben Hansen

Thanks a lot. Very nicely put together.

07 Nov 2014 Arthur Allen

Update for 2014B: make the changes below to
function PPTXInfo = addPicture(PPTXInfo,imgData,varargin)

I have NOT check all variations of exportToPPTX in 2014B

My earlier problems, where my own errors in having a mismatch between 'new' at start of my scrip and 'save' at the end.

23 Sep 2014 Jack

Jack (view profile)

Stefan. Fantastic application!! It has saved me a great deal of effort in making changes to my COM application. I had to update when it went from 2007 to 2010 and now I am faced once again with updating. You have saved me that work.

I noticed that if I create a power point, save and close it, then re-open I have problems adding a picture or notes if the original power point didn't have pictures or notes in it.

I think the problem is related to creating directories.

Thank you for the great application.

26 Aug 2014 Dr. Rami Khushaba

Thanks a million, you saved me a lot of time and effort.

06 Aug 2014 Andrew Barnard

HI Stefan. This is great. Thank you
I do have one problem thou. I can load an existing pptx. But how do I change to an current slide and add new text/etc to it. Currently you only seem to add anew slide onto the end and them add new text etc to that one. Thank you

06 Aug 2014 gooey

gooey (view profile)

04 Aug 2014 Mcdavis fasugba

Hi Stefan,
This is a very nice script and I have been using it a lot and building more complex code around it. thanks for your work.
I do have some questions:
Is there a way to select custom themes? My company has its own theme it uses for presentations. Thanks

02 Jul 2014 Stefan Slonevskiy

Norman, font type is currently not supported. I will add it when I get some free time. exportToPPTX does not handle templates at this time, so you can't select slide layout. I am slowly working on adding a this feature though.

Comment only
02 Jul 2014 Norman

Norman (view profile)

02 Jul 2014 Norman

Norman (view profile)

Great Example!

Is there a way to change the Font Type?

Also is the a way when adding a new slide you tell it what layout to use?

Thank you in advance.

Comment only
10 Jun 2014 Stefan Slonevskiy

Hans, exportToPPTX will not be able to add a movie to the slide at this time. But it won't be too hard to add this feature. So I will add it to the list of things to do...

Comment only
09 Jun 2014 Hans

Hans (view profile)

Say that I make an animation in MATLAB using movie().
Can I use exportToPPTX to export it to ppt?

Comment only
25 Apr 2014 Aaron

Aaron (view profile)

Excellent supplementary tool. Easy to integrate into existing code and simplify report generation.

15 Mar 2014 Stefan Slonevskiy

wei, you can use any format you want as long as PowerPoint supports it. It supports PNG, JPG, GIF, BMP, TIF and many others raster image formats. EMF format is an example of vector file formats. Another example would be EPS. Using vector format has an advantage of being able to zoom in as much as you want without losing details. However with complicated figures vector format very quickly becomes large in size. I included EMF in the examples_exportToPPTX script just to show that exportToPPTX supports vector formats.

Comment only
24 Jan 2014 grega

grega (view profile)

Nice script, but Im keep on getting the error message:
Error using copyfile
The system cannot find the path specified.
-> 881 copyfile(imgData,imagePath);

I used: addPicture(PPTXInfo,'myPic.bmp',varargin)
Any solution pls?

Comment only
02 Jan 2014 Jonathan  
20 Oct 2013 virginia

amazing!!! :D

12 Oct 2013 wei

wei (view profile)

Very nice work, However, saveas(...,emf) in examples_exportToPPTX could not properly work in MAC OS, Could you change this to another formate, such as jpeg or png.

Comment only
11 Oct 2013 John D'Errico

John D'Errico (view profile)

What a useful tool!

11 Oct 2013 Jiro Doke

Jiro Doke (view profile)

Very nice, Stefan!

A couple of requests.
1. I would like to be able to apply existing templates to the PPTX.
2. It would be nice to apply a standard layout, such as title slide, agenda slide, title and content, title and two contents, etc.
3. Related to #2, once I apply a standard layout, I would like to put in text to the standard text box, instead of adding a new text box.

03 Oct 2013 mylyu

mylyu (view profile)

03 Oct 2013 mylyu

mylyu (view profile)

It works well with office 2013. Thanks.

29 Sep 2013 Stefan Slonevskiy

Lube F, I have just submitted an updated version that seems to work with Office 2010. I say "seems" because I was only able to test it with PowerPoint 2010 Viewer. I do not have an access to a full-blown Office 2010 at the moment. Please let me know if you still see the issue. Updated version should appear on here in a few days, or you can get it now from GitHub. Thanks!

Comment only
18 Sep 2013 Lube F

Lube F (view profile)

aahhh what happened to my first comment?!!
what i said was:
fantastic submission, but i've run into the 2010 corruption bug you mention here:
and then i went off for a while to try to work out the problem, and the only thing i found to work was...

Comment only
18 Sep 2013 Lube F

Lube F (view profile)

ok well a crappy workaround is to open with powerpoint 2007 viewer then use a pdf printer to create a pdf, and then use a pdf to pptx converter. it does the job but obviously it's not ideal!
perhaps you could also workaround with openoffice?

13 May 2013 p kung

p kung (view profile)

Hi, Stefan

i have found 2 problems:

1. if you create a new PPTX without specifying the dimensions, (PPTX default = 10" x 7.5")

then if you want to save (append) to the same PPT file the 2nd time, it throws an error @ about line 402:

about "createdDate" does not exist:

PPTXInfo = rmfield(PPTXInfo, ....)

it appears that createdDate is assigned only if the dimensions are explicitly given.

so right now, i always give dimensions.

2. the axis scale does not seem to stick.

it always appears to be auto-scale. so my workaround is always use "saveas" in a temporary png file then add it in PPT/



02 May 2013 p kung

p kung (view profile)

thanks Stefan for such a speedy response

works beautifully, exactly what i need.

02 May 2013 Stefan Slonevskiy

Thanks, p kung. Latest version is up, it should now work with multiple images properly. Let me know if you see any other bugs.

Comment only
30 Apr 2013 p kung

p kung (view profile)

Jonathan is right,

i also can't create 4 different plots on the same figure. they're all identical.

in your example, you plot earth 4 times & put them in 2x2 plots on a slide.

now i want to plot 4 different plots/images & put them in 2x2 plots on one slide.

somehow, the 2x2 plots are of the same image (last plot) 4 times.

if you could kindly fix this bug, i'd give it 5 stars.


26 Mar 2013 Stefan Slonevskiy

In terms of capturing screen rather than figures, this is a known getframe limitation. See MathWorks' article on a potential workaround: You can use hardcopy method to get figure/axis CDATA and then just pass that to exportToPPTX. An example of passing CDATA to exportToPPTX is available in examples_exportToPPTX.m

Comment only
26 Mar 2013 Stefan Slonevskiy

To save figures in another file format use MatLab's imwrite function to write to a temporary file and then call exportToPPTX with that filename. For example:
img = getframe(gcf);
exportToPPTX('addpicture','temp.jpg','Position',[6 3.5 3 2]);

In terms of plans for notes support, I was hoping to add it at some point.

Comment only
26 Mar 2013 Matlab User

With MATLAB running in the background--and exportToPPTX being called from within a nested loop--I was using Firefox in the foreground. When the MATLAB simulation complete, I noticed screen shots of my web browsing session appearing in the PPTX files produced by exportToPPTX. Furthermore, it would also appear that if the PC is "locked" during a simulation, then the exportToPPTX pastes completely black figures into the PPTX file.

Apart from neither locking my PC nor using it for anything else during a simulation, is there an alternative way of ensuring that the figures are not corrupted?

Comment only
26 Mar 2013 Matlab User

Thanks for this excellent function which provides massive speed improvements compared to the COM method.

When using the function within a loop, I found that I had to clear PPTXInfo to avoid an error that occurred the second time the function was called. On line 394, I replaced "PPTXInfo.fileOpen = false;" with "clear PPTXInfo".

A couple of questions:

Figures are pasted into the PPTX as PNG. Would it possible to paste using a different graphics format?

Do you have plans to allow slide notes to be added?

18 Mar 2013 John

John (view profile)

13 Mar 2013 Stefan Slonevskiy

Jonathan, I tested it with four images (in the examples_exportToPPTX.m script) and it worked fine. Can you please provide more details about this bug?

Comment only
13 Mar 2013 Jonathan Sullivan

This is great.

However, I did encounter a bug. It seems as though you can only have unique image per slide. This is quite limiting. If you can fix this bug, I'd gladly change my rating to 5 stars

13 Mar 2013 Stefan Slonevskiy

Thanks for the suggestion, Darik. I have added this and a few other options to the latest version.

Comment only
11 Mar 2013 Darik

Darik (view profile)

Nice work. This is definitely a lot faster than the alternative COM implementations. I suppose the trade-off is that you can't export to a file if it's already open in Powerpoint.

I'd suggest you split the addpicture method up into 'addfigure' and 'addimage'. The latter could accept a png file as input instead of a figure handle, which would make your function a lot more compatible with all the other exporting functions on the FEX, such as export_fig.

Comment only
11 Mar 2013 Darik

Darik (view profile)

13 Mar 2013

* Throw a more descriptive error if there is one when writing PPTX file
* Support additional input types for addPicture
* Add additional textbox and image formatting options

02 May 2013

Fixed bug that caused multiple images to override each other on a single slide.

12 Aug 2013

added ability to add notes to slides, plus fixed a number of bugs

17 Sep 2013

- Add "BackgroundColor" option to slides
- Fixed bug with Unicode file content
- Fixed invalid PPTX files on some versions of PowerPoint
- Fixed paragraph breaks in multi-line textboxes

30 Sep 2013

Fixed (hopefully) Office 2010 compatibility issue

03 Feb 2015

Linked to GitHub version

Contact us