This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

mlreportgen.dom.DOCXSubDoc class

Package: mlreportgen.dom

Reference to external Microsoft Word document


Reference to external Microsoft® Word document.


docxSubDocObj = DOCXSubDoc() creates an empty document reference.

docxSubDocObj = DOCXSubDoc(path) creates a reference to a Word document at the specified path. Appending this reference to a Word document (the master document) inserts a link to the subdocument at the point at which the reference is appended.

Opening a master document in Word causes the link to the subdocument to be displayed, instead of its content. To replace the link with the content, select Expand Subdocuments from the Outlining tab of the View tab on the Word toolstrip.

The rptview command expands subdocuments when it opens a Word document. You can also use docview to expand and unlink subdocuments.

Input Arguments

expand all

Path of document targeted by this reference, specified as a character vector.

Output Arguments

expand all

Path of Word document targeted by this reference, represented by an mlreportgen.dom.DOCXSubDoc object.


expand all

ID for this document element, specified as a character vector. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Tag for document element, specified as a character vector.

A session-unique ID is generated as part of document element creation. The generated tag has the form CLASS:ID, where CLASS is the class of the element and ID is the value of the Id property of the object. You can specify a tag to replace the generated tag.

For example, to make it easier to identify where an issue occurred during document generation, you can specify your own tag value.

Path of document targeted by this reference, specified as a character vector. Use ASCII characters. Use the following format for specifying a full path involving a mapped drive.






Use DOCXSubDoc.clone in a similar way to how you use Paragraph.clone.

Clone this Word document reference.


collapse all

import mlreportgen.dom.*

info = Document('CompanyInfo','docx');
append(info,'XYZ, Inc., makes widgets.');

infoPath = info.OutputPath;

rpt = Document('Report','docx');

append(rpt,Paragraph('About XYZ, Inc.'));