Main Content

docview

View or perform operations on Word document

Description

example

[status,message] = docview(filename) opens and displays the specified file as a Word document. Returns success or failure and, if appropriate, an error message.

example

[status,message] = docview(filename,option) specifies an operation to perform in Word. The operation requires Microsoft® Word on a Windows® platform.

example

[status,message] = docview(filename,option1...optionN) specifies one or more operations to perform in Word. The operations require Microsoft Word on a Windows platform.

Examples

collapse all

Open a document in RTF format in Word. This example assumes the document magic-squares.rtf is on the MATLAB® path.

docview('magic-square.rtf');

Print a document. This example assumes the document mydoc.doc is on the MATLAB path.

docview('mydoc.doc','printdoc');

Use docview to update TOC fields in a document, convert the document to PDF, and close a Word document. This command creates the document mytocdoc.pdf in the current folder. This example assumes the document mytocdoc.docx is on the MATLAB path.

docview('mytocdoc','updatedocxfields','convertdocxtopdf','closeapp');

Input Arguments

collapse all

Name of file to view, print, or update, specified as the full path name.

Operation to perform in Microsoft Word on a Windows platform, specified as one of these values:

  • 'updatefields' — Update fields, such as the TOC.

  • 'updatedocxfields' — Update fields in a DOCX document.

  • 'convertdocxtopdf' — Convert a DOCX document to PDF.

  • 'showdocxaspdf' — Convert a DOCX document to PDF and open in a PDF viewer.

  • 'unlinkdocxsubdoc' — Replace links to other documents with the content of those documents. To learn about subdocuments, see mlreportgen.dom.DOCXSubDoc.

  • 'printdoc' — Print the document. The document must be open In Word before you use this option.

  • 'savedoc' — Save the document.

  • 'closedoc' — Close the document.

  • 'closeapp' — Close Word, if no document is open.

Output Arguments

collapse all

Success status of the specified actions, returned as 0 when the action was not completed and 1 for success.

Error or warning information, returned as a character vector.

Introduced before R2006a