Main Content

mlreportgen.dom.DOCXSubDoc class

Package: mlreportgen.dom

Reference to external Microsoft Word document

Description

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 DOCXSubDoc object.

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 toolstrip. The rptview command expands subdocuments when it opens a Word document. You can also use docview to expand and unlink subdocuments.

The mlreportgen.dom.DOCXSubDoc class is a handle class.

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

docxSubDocObj = mlreportgen.dom.DOCXSubDoc() creates an empty document reference.

example

docxSubDocObj = mlreportgen.dom.DOCXSubDoc(path) creates a reference to a Word document at the specified path and sets the Target property to path.

Properties

expand all

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.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

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 of the Id property of the object. Specifying your own tag value can help you to identify where an issue occurred during document generation.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

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.

'file:///C:/UserPath/FileName.docx'

Attributes:

GetAccess
public
SetAccess
immutable
Transient
true
NonCopyable
true

Methods

expand all

Examples

collapse all

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);

Alternative Functionality

mlreportgen.dom.EmbeddedObject

To insert documents other than Word documents into another document, use objects of the mlreportgen.dom.EmbeddedObject class.

To insert Word documents into another document, you can use objects of the DOCXSubDoc or EmbeddedObject class. To decide which class to use, consider these guidelines:

  • Use 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 rptview.

  • Use EmbeddedObject objects if you want to move the parent document without moving the subdocuments.

Introduced in R2014b