No BSD License  

Highlights from
MATLAB controls and writes PowerPoint

4.4
4.4 | 5 ratings Rate this file 32 Downloads (last 30 days) File Size: 1.53 KB File ID: #18457 Version: 1.0

MATLAB controls and writes PowerPoint

by

 

24 Jan 2008 (Updated )

MATLAB as a COM client, Microsoft PowerPoint (or any Office 2003 application) as a COM server

| Watch this File

File Information
Description

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.

Acknowledgements

Saveppt inspired this file.

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Windows only
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
14 Apr 2015 Shaan

Shaan (view profile)

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)

Error using
Interface.Microsoft_PowerPoint_15.0_Object_Library.Shapes/AddPicture
Invoke Error, Dispatch Exception:

Description: The specified file wasn't found.

01 Dec 2014 dashen

dashen (view profile)

 
03 Mar 2014 Jason

Jason (view profile)

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
Presentation.Slides.invoke
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:
>http://www.mathworks.com/matlabcentral/answers/99150

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:
winopen('ExamplePresentation.ppt')

12 Mar 2012 Scott

Scott (view profile)

Found a work around to ppt.Visible=0 not working.

op=invoke(ppt.Presentations,'Add',0)

12 Mar 2012 Scott

Scott (view profile)

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

Comment only
11 Jan 2012 Van

Van (view profile)

This code easily works, but for Office 2010, it fails.

Comment only
14 Sep 2009 Rodrigo Carvallo

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

Comment only
19 Jun 2009 Andres

Andres (view profile)

Very helpful demo script to get started. Thanks!

Contact us