Skip to main content
Skip table of contents

importContent

A Word content command that replaces the contents of its content control with the body contents of another DOCX document. Any Word content commands in that DOCX document will be evaluated before this import process. Besides just the content, this import process also brings in the styles that the content uses in the other document, but see the documentation of the renameConflictingStyles attribute for one complication in this process.

If this command is used in an inline-level content control that exists within a paragraph, eg. a content control wrapping a single word within a paragraph, the composed result differs slightly depending on the contents of the other DOCX document. If the imported content consists of a single paragraph, the text of that paragraph is merged into the paragraph the content control is in - much in the same way as how out works. If the imported content consists of more than a single paragraph, the paragraph the content control is split into two paragraphs and the content from the other document will appear between these paragraphs.

This command has a priority of 25.

importContent does not work within an evaluation process that is started by another importContent. In other words, if the DOCX document specified with the data attribute contains any importDocument commands, they will not do anything.

Syntax:

importContent(data,renameConflictingStyles)

With required attributes only:

importContent(data)

#1 - data

Required

Value type

EL-evaluated

Yes

File

Yes

Defines the document whose contents are brought into the content control. The resolved File value is expected to be a DOCX document. 

#2 - renameConflictingStyles

Required

Value type

EL-evaluated

No

Boolean

No

Defines how the styles of the imported contents of the DOCX document defined with data are handled. This specifically concerns any styles in use that have the same names as styles existing in this document, a common example being the built-in style "Normal", as two styles with the same name cannot co-exist. This attribute defines what will happen if a style conflict like this occurs.

  • If the resolved value is true, the conflict is resolved by renaming the conflicting style of the other document and then importing it alongside the content. The imported content using this style is then altered to use the renamed style. This allows the imported content to retain its original appearance as it is in the other document.

  • If the resolved value is false, the conflict is resolved by not importing the conflicting style. The imported content will then use the style of that name already existing in this document.

Regardless of the value of this attribute, any styles used in the imported content with non-conflicting names are brought in as is.

If undefined, the value of false is used, so no style renaming will occur.

Examples

The importContent command should be relatively easy to use as you are only required to specify the document to import.

CODE
importContent(productTableDoc)

While importContent could also be used to bring appendices at the end of your document, the command mergeDOCX tends to be more suited for that purpose. The specialty of importContent is primarily its capability of bringing ntent into any point of the document.

The second attribute renameConflictingStyles has a long description, but what it does is relatively simple. Let's say that the imported content contains a paragraph using the style "Normal" that in that document specifies the font as Times New Roman. The document this command is in has the "Normal" style as well, but here the font is set to Calibri. If renameConflictingStyles is undefined or false, the imported paragraph will continue to use the "Normal" style and so will appear in the composed document with its font as Calibri. If renameConflictingStyles is true, the imported paragraph in the composed document will instead appear to use a style called something like "Normalxe57e7821-a42f-41b3-81d7-f09eb5811ca9", which then defines the paragraph's font as Times New Roman. Leaving the attribute undefined is therefore a good choice if you'd prefer the imported content to blend with existing content.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.