Reference to external Microsoft Word document
Use an object of the
mlreportgen.dom.DOCXSubDoc class to create a
reference to an external Microsoft® Word document in a Word, PDF, or HTML document. A link to the referenced
document (also known as a subdocument) is inserted in the parent
document where you append the
When you initially open the parent document in Word, Word displays the link to the
subdocument instead of the content. To replace the link with the content, select
Expand Subdocuments from the
Outlining tab of the View tab on the Word
rptview command expands subdocuments when it opens a
Word document. You can also use
docview to expand and unlink
mlreportgen.dom.DOCXSubDoc class is a
For information on class attributes, see Class Attributes.
Id— ID for this DOM API object
ID for this DOM API object, specified as a character vector or string scalar. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.
Tag— Tag for this DOM API object
Tag for this DOM API object, specified as a character vector or string scalar.
The DOM generates a session-unique tag as part of the creation of this object. The
generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value
Id property of the object. Specifying your own tag value can
help you to identify where an issue occurred during document generation.
Target— Path of document targeted by this reference
Path of document targeted by this reference, specified as a character vector or string scalar. Use ASCII characters. Use the following format for specifying a full path involving a mapped drive.
import mlreportgen.dom.* info = Document('CompanyInfo','docx'); append(info,'XYZ, Inc., makes widgets.'); close(info); infoPath = info.OutputPath; rpt = Document('Report','docx'); open(rpt); append(rpt,Paragraph('About XYZ, Inc.')); append(rpt,DOCXSubDoc(infoPath)); close(rpt); rptview(rpt.OutputPath);
To insert documents other than Word documents into another document, use objects
To insert Word documents into another document, you can use objects of the
EmbeddedObject class. To decide
which class to use, consider these guidelines:
DOCXSubDoc objects if you want the parent document
to display links to subdocuments initially. You might want to display
links initially when the parent document links to a set of subdocuments
in an outline view. Use
EmbeddedObject objects if you
want the parent document to display the subdocument contents regardless
of whether you open the parent document in Word or by using
EmbeddedObject objects if you want to move the
parent document without moving the subdocuments.