Main Content

mlreportgen.dom.DOCXSubDoc Class

Namespace: 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

Object identifier for mlreportgen.dom.DOCXSubDoc object, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object. You can specify your own value for Id.

Attributes:

NonCopyable
true

Data Types: char | string

Tag for mlreportgen.dom.DOCXSubDoc object, specified as a character vector or string scalar. The DOM API 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. Specify your own tag value to help you identify where to look when an issue occurs during document generation.

Attributes:

NonCopyable
true

Data Types: char | string

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.

Version History

Introduced in R2014b