Main Content

docview

View or perform operations on Word document

Description

example

docview(filename) opens and displays the specified file in Microsoft® Word or an editor compatible with Word, such as OpenOffice. Word or an editor compatible with Word must be installed.

[status,message] = docview(filename) also returns success or failure and, if appropriate, an error message.

example

docview(filename,operation1,...,operationN) specifies one or more operations to perform in Word. The operations require Microsoft Word on a Windows® platform.

[status,message] = docview(filename,operation1,...,operationN) also returns success or failure and, if appropriate, an error message.

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.

Operations to perform in Microsoft Word on a Windows platform, specified as one or more 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.

  • 'printdocscaled' — Prints the document scaled to the locale-specific page size, such as US Letter or A4.

  • '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