Package: mlreportgen.utils
Superclasses:
Methods for interacting with Microsoft Word application and documents
This utility provides methods for interacting with the Word application and Word documents. These methods use the MATLAB® interface to the Microsoft® .NET Framework to interact with the Word editor.
wordApp = mlreportgen.utils.word.start()
Start the Word application if it has not already been started and return a
wordApp
object. A wordApp
object is a MATLAB object that wraps the .NET object that wraps the Word editor. The Word
application is hidden.
wordDoc = mlreportgen.utils.word.load(filename)
Load an existing Word document file specified in filename
and return
a wordDoc
object. A wordDoc
object is a MATLAB object that wraps the .NET object that wraps the Word document.
wordDoc = mlreportgen.utils.word.open(filename)
Open a Word document file specified in filename
, make it visible, and
return a wordDoc
object. A wordDoc
object is a
MATLAB object that wraps the .NET object that wraps the Word document.
tf = mlreportgen.utils.word.close tf = mlreportgen.utils.word.close(true) tf = mlreportgen.utils.word.close(false) tf = mlreportgen.utils.word.close(filename) tf = mlreportgen.utils.word.close(filename,true) tf = mlreportgen.utils.word.close(filename,false)
For empty or no input, close Word application only if there are no unsaved Word documents.
For true
input, close Word application only if there are no unsaved
Word documents or there are no Word documents open outside of MATLAB.
For false
input, close Word application even if there are unsaved
Word documents or if there are Word documents opened outside of MATLAB.
For each of these syntaxes, return true
if application is closed or
false
if application remains open.
For filename
input, close Word document specified as
filename
only if there are no unsaved changes.
For filename
and true
inputs, close Word
document file, specified as filename
, only if there are no unsaved
changes.
For filename
and false
inputs, close Word
document file, specified as filename
, even if there are unsaved
changes.
For each of these syntaxes:
Hide word application if there are no other open Word documents.
Return true
if Word document is closed
Return false
if Word document remains open
tf = mlreportgen.utils.word.closeAll() tf = mlreportgen.utils.word.closeAll(true) tf = mlreportgen.utils.word.closeAll(false)
For empty input, close all Word document files and hide the Word application.
For true
input, close all Word document files only if there are no
unsaved changes.
For false
input, close all Word document files even if there are
unsaved changes.
For each of these syntaxes:
Hide the Word application if there are no other open Word documents
Return true
if all Word document files are closed
Return false
if any Word document remains open
wordApp = mlreportgen.utils.word.show() wordDoc = mlreportgen.utils.word.show(filename)
For empty input, make the Word application or document file visible and return the
wordApp
object.
For filename
input, make the specified Word document file visible and
return the wordDoc
object.
wordApp = mlreportgen.utils.word.hide() wordDoc = mlreportgen.utils.word.hide(filename)
For empty input, hide the Word application or document and return the
wordApp
object.
For filename
input, hide the specified Word document file and return
the wordDoc
object.
files = mlreportgen.utils.word.filenames()
Return a string array of file names for open Word document
files
.
tf = mlreportgen.utils.word.isAvailable()
Verify whether Word is available for use. Return true
if Word is
available or false
if it is not available.
tf = mlreportgen.utils.word.isStarted
Verify whether Word application is started. Return true
if Word is
started or false
if it is not started.
tf = mlreportgen.utils.word.isLoaded(filename)
Verify whether Word document file is loaded. Return true
if Word
document filename
is loaded or false
if it is not
loaded.
wordApp = mlreportgen.utils.word.wordapp()
Return wordApp
object. An error occurs if Word is not started.
wordDoc = mlreportgen.utils.word.worddoc(filename)
Return wordDoc
object that wraps the Word document file specified in
filename
. An error occurs if the Word document file is not open.
Open the test.docx
and test1.docx
Word documents,
which are in the current working folder.
wordDoc = mlreportgen.utils.word.open('test') wordDoc1 = mlreportgen.utils.word.open('test1')
wordDoc = WordDoc with properties: FileName: 'C:\Users\username\Documents\test.docx' wordDoc1 = WordDoc with properties: FileName: 'C:\Users\username\Documents\test1.docx'
Obtain the file names of open Word document files.
files = mlreportgen.utils.word.filenames()
files = 1×2 string array "C:\Users\username\Documents\test.docx" ... "C:\Users\username\Documents\test1.docx"