Main Content

mlreportgen.utils.powerpoint class

Package: mlreportgen.utils
Superclasses:

Interact with PowerPoint application and presentations

Since R2018b

Description

This utility provides methods for interacting with the PowerPoint® application and PowerPoint presentations. These methods use the MATLAB interface to the Microsoft .NET framework to interact with the PowerPoint editor.

Methods

start

pptApp = mlreportgen.utils.powerpoint.start()

Start the PowerPoint application if it has not already been started and return a pptApp object. A pptApp object is a MATLAB object that wraps the .NET object that wraps the PowerPoint editor. The PowerPoint application is hidden.

load

pptPres = mlreportgen.utils.powerpoint.load(filename)

Load an existing PowerPoint presentation file specified in filename and return a pptPres object. A pptPres object is a MATLAB object that wraps the .NET object that wraps the PowerPoint presentation.

open

pptPres = mlreportgen.utils.powerpoint.open(filename)

Open a PowerPoint presentation file specified in filename, make it visible, and return a pptPres object. A pptPres object is a MATLAB object that wraps the .NET object that wraps the PowerPoint presentation.

close

tf = mlreportgen.utils.powerpoint.close
tf = mlreportgen.utils.powerpoint.close(true)
tf = mlreportgen.utils.powerpoint.close(false)

tf = mlreportgen.utils.powerpoint.close(filename)
tf = mlreportgen.utils.powerpoint.close(filename,true)
tf = mlreportgen.utils.powerpoint.close(filename,false)
Close PowerPoint Application

For empty or no input, close the PowerPoint application only if there are no unsaved PowerPoint presentations.

For true input, close the PowerPoint application only if there are no unsaved PowerPoint presentations.

For false input, close the PowerPoint application even if there are unsaved PowerPoint presentations or if there are PowerPoint presentations opened outside of MATLAB.

For each of these syntaxes, return true if application is closed or false if application remains open.

Close PowerPoint Presentation

For filename input, close the PowerPoint presentation specified as filename only if there are no unsaved changes.

For filename and true inputs, close the PowerPoint presentation, specified as filename, only if there are no unsaved changes.

For filename and false inputs, close the PowerPoint presentation, specified as filename, even if there are unsaved changes.

For each of these syntaxes,

  • Hide the PowerPoint application if there are no other open PowerPoint presentations.

  • Return true if the PowerPoint presentation file is closed

  • Return false if the PowerPoint presentation file remains open

closeAll

tf = mlreportgen.utils.powerpoint.closeAll()
tf = mlreportgen.utils.powerpoint.closeAll(true)
tf = mlreportgen.utils.powerpoint.closeAll(false) 

For empty input, close all PowerPoint presentation files and hide the PowerPoint application.

For true input, close all PowerPoint presentation only if there are no unsaved changes.

For false input, close all PowerPoint presentation files even if there are unsaved changes.

For each of these syntaxes:

  • Hide the PowerPoint application if there are no other open PowerPoint presentation files

  • Return true if all PowerPoint presentation files are closed

  • Return false if any PowerPoint presentation file remains open

show

pptApp = mlreportgen.utils.powerpoint.show()
pptPres = mlreportgen.utils.powerpoint.show(filename) 

For empty input, make the PowerPoint application or PowerPoint presentation file visible and return the pptApp object.

For filename input, make the specified PowerPoint presentation file visible and returns the pptPres object.

hide

pptApp = mlreportgen.utils.powerpoint.hide()
pptPres = mlreportgen.utils.powerpoint.hide(filename) 

For empty input, hide the PowerPoint application or PowerPoint presentation and returns the pptApp object.

For filename input, hide the specified PowerPoint presentation file and returns the pptPres object.

isAvailable

files = mlreportgen.utils.powerpoint.filenames() 

Return a string array of file names for open PowerPoint presentation files.

isAvailable

tf = mlreportgen.utils.powerpoint.isAvailable() 

Verify whether PowerPoint is available for use. Return true if PowerPoint is available or false if it is not available.

isStarted

tf = mlreportgen.utils.powerpoint.isStarted

Verify whether PowerPoint application is started. Return true if PowerPoint is started or false if it is not started.

isLoaded

tf = mlreportgen.utils.powerpoint.isLoaded(filename)

Verify whether PowerPoint presentation file is loaded. Return true if PowerPoint presentation filename is loaded or false if it is not loaded.

pptapp

pptApp = mlreportgen.utils.powerpoint.pptApp() 

Return pptApp object. An error occurs if PowerPoint is not started.

pptpres

pptPres = mlreportgen.utils.powerpoint.pptPres(filename)

Return pptPres object that wraps the PowerPoint presentation file specified in filename. An error occurs if the PowerPoint presentation file does not exist.

Examples

Open PowerPoint Presentations

Open the test.pptx and test1.pptx PowerPoint presentations, which are in the current working folder.

pptPres = mlreportgen.utils.powerpoint.open('test')
pptPres1 = mlreportgen.utils.powerpoint.open('test1') 
pptPres = 

  PPTPres with properties:
    FileName: 'C:\Users\username\Documents\test.pptx'

pptPres1 = 

  pptPres with properties:
    FileName: 'C:\Users\username\Documents\test1.pptx'

Obtain PowerPoint Presentation File Names

Obtain the names of open PowerPoint presentation files.

files = mlreportgen.utils.powerpoint.filenames()
files = 

  1×2 string array

    "C:\Users\username\Documents\test.pptx" ...
    "C:\Users\username\Documents\test1.pptx"

Version History

Introduced in R2018b