Matlab and Microsoft Office PowerPoint
It is always important to turn our work into a nice documentation. Apart form m-file publishing, Matlab give us no help. Fortunately on Matlab file Exchange several authors published a series of routines that let us interface Matlab with the most important Softwares of the Microsoft Office Package. A few months ago we already discussed about some functions to interface with Excel. Today we show the list for Microsoft Office Power Point.
saveppt
This function saves Matlab figure windows or Simulink models to a Powerpoint file in metafile format using the ActiveX interface. The figure or model is first copied to the Windows clipboard, Powerpoint is started, a new blank slide is added, the figure/model is pasted, the file is saved, and Powerpoint is closed. If the Powerpoint file does not exist, a new one is created. An optional input argument allows you to add a unique title to the PowerPoint slide when it is created. This routine is handy when a large number of graphics must be inserted into Powerpoint, such as within a FOR loop. It is also a good example of how to use ActiveX to move Matlab graphics to other Windows programs.
Version 2.2 allows figures to be saved quietly in the background without PPT being visible.
MATLAB controls and writes PowerPoint
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 above. 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.
subplotPPT
Saves multiple MATLAB figure windows to powerpoint giving the user “subplot” style control over their positions in the final slide.
Given multiple figures you can use commands like:
subplotPPT(m,n,k,…) to print a copy of the figure to a powerpoint slide. The first three arguements behave like those of subplot: m rows of images, n columns amd k gives you the index of the image to paste to (if k has two element per image then the function will merge the image across the locations). Other inputs:
- Vector of handles to figures to paste into the slide
- Filename of powerpoint file to use slide number to print to
- Region of the slide to print to image file format to print to (e.g jpg, png, bmp …) gaps between adjacent images units for specifying measures in.
The zip file contains subplotPPT and test_PPTScript which runs through some examples of how to call the function
Example:
The code:
h(1) = figure; peaks; h(2) = figure; membrane; h(3) = figure; spy; h(4) = figure; image; h(5) = figure; tori4; subplotPPT(3,3,... [1 4; 2 3; 5 5; 6 9; 7 8],... h,[pwd,filesep,'test.ppt'],4,... 'region',[200 100 500 340],... 'hgap',10,'vgap',10,'units','pixels');
Generates the screenshot
saveppt2
saveppt2 builds on saveppt to include many new options.
- Saveppt2 Features:
- Save multiple plots to the same PowerPoint slide.
- Create slides with and without a title.
- Add notes to a PowerPoint slide
- Scale the figure to fill the slide (with and without locking aspect ratio).
- Horizontally and vertically align figures on the slide.
- Use a template file for creating a new presentation. (Useful for automated reports)
- Add padding to any of the sides for use with scaling or aligning figures.
New in Jun 2010.
- Can choose between Metafile or bitmap drivers when copy and pasting to PowerPoint.
- Add a blank title page or blank page from Matlab.
- Add comments & textbox to slide.
- Make PowerPoint visible during operations. (Required for Comments).
- If there is another PowerPoint presentation open, PowerPoint will not quit.
- Disable closing of PowerPoint presentation and return ActiveX object for further programmatic slide manipulation.
Also added a method to do batch processing by keeping an ActiveX session open and just adding new slides to it.
ppt=saveppt2('batch.ppt','init'); for i=1:10 plot(rand(1,100),rand(1,100),'*'); saveppt2('ppt',ppt) end saveppt2('batch.ppt','ppt',ppt,'close');
The zip file includes saveppt2 and a sample presentation created with saveppt2. The code for creating the presentation is also included.
–
GitHub Project:
http://github.com/jedediahfrey/Jedediah-Frey-s-MATLABCentral-Projects
Popularity: 2% [?]
Related Posts
Comments
One Comment on Matlab and Microsoft Office PowerPoint
-
Cassandra on
Fri, 11th Jun 2010 17:25
Thanks for writing about MATLAB’s capabilities with PowerPoint. It is always important to turn your work into an eye-catching and profession document, and the Office applications are always nearby to help you out!
We’d love to have you join the Office page on Facebook and share your tips with the community. You can find the page at http://www.facebook.com/office. And, with the Office 2010 release just around the corner, you can pre-order your copy today at http://store.microsoft.com/Category.aspx?CatId=210
Cheers,
Cassandra
Microsoft Office Outreach
[Reply]
Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!
Include MATLAB code in your comment by doing the following:
<pre lang="MATLAB">
%insert code here
</pre>


















































