The MATLAB functions XLSREAD and XLSWRITE open Microsoft Excel as a COM Automation Server in the background, and read or write data. Using the same mechanism, it is possible to open, write to, and fully control Microsoft PowerPoint from MATLAB. The advantage is that from a single tool, both the data analysis and the presentation creation can be scripted.
This is the same functionality used in Mark Brown's submission referenced below. Mark Brown's "saveppt.m" is a cleanly packaged solution, whereas this submission is an open script intended to show what's going on, and empower users to create their own customized "pptwrite" functions.
It's very useful to me
Thanks for sharing this code
The code gives an error at this line with Powerpoint 2013
Image1 = Slide1.Shapes.AddPicture('C:\...\test1.png','msoFalse','msoTrue',100,20,500,500)
Invoke Error, Dispatch Exception:
Description: The specified file wasn't found.
Excellent intro and well commented.
Some helpful tips I uncovered for more recent versions of PowerPoint:
Replace the add-slides section:
%% ADD SLIDES
% View the methods that can be invoked
blankSlide = Presentation.SlideMaster.CustomLayouts.Item(7)
% Add two slides via "Add" method
Slide1 = Presentation.Slides.AddSlide(1,blankSlide)
Slide2 = Presentation.Slides.AddSlide(2,blankSlide)
>Modified from 2007 example at:
I would also Find/Replace "'C:\..." with "[cd,'" and then close out the arrays at the replacement locations in this script.
This tweak should allow the code to run as-is in any location for example purposes.
Add this to the last line to open your presentation once the script finishes:
Found a work around to ppt.Visible=0 not working.
As of PPT 2010, you can no longer hide the application (ppt.Visible=0). You can only minimize it (ppt.WindowState = 2). However, you can still open a presentation hidden using
op = invoke(ppt.Presentations,'Open',filespec,,,0);
This code easily works, but for Office 2010, it fails.
Im a begginner using matlab and im interested in writting ppts from matlab 6.5 to microsoft ppt 2003.
I tried with this code but i couldnt do it. Someone knows how to use this code in 6.5. Do you have to change some lines of the code or something else to have success using this?
Is there another useful code to write ppt 2003 from matlab 6.5?
Thanks in Advance
Very helpful demo script to get started. Thanks!