Unlinking the sub-document is a feature of Word API to import the sub-document of the group document.
This section provides an overview of Microsoft Word group documents and unlinking sub-documents in Word API.
The sub-document of the group document is a link (reference) to the target file, and the master document only displays the contents of the linked file.
By unlinking the sub-document, you can import the contents of the sub-document into the master document and make it into single file.
The image below shows the procedure for creating a group document with "MasterDocument.docx" as the master document and "AboutGroupDocument.docx" and "GroupDocumentStyle.docx" as sub-documents.
A group document can be created by opening "MasterDocument.docx" and selecting a sub-document files from [View]-[Outline]-[Master Document]-[Show Document]-[Insert].
First, as shown in the image below, define the style name of "MyTable" to the documents "MasterDocument.docx (master document)", "AboutGroupDocument.docx (sub-document)" and "GroupDocumentStyle.docx (sub-document)".
What is important at this time is that the style definition of "GroupDocumentStyle.docx (sub-document)" is different.
"AboutGroupDocument.docx (sub-document)" can be inserted without any problem.
However, when inserting "GroupDocumentStyle.docx (sub-document)", a dialog asking if you want to keep the style is displayed as shown in the image below.
This is because there are identical style names with different style definitions.
If you select [No] in the displayed dialog, the style on the "GroupDocumentStyle.docx (sub-document)" side will be discarded, and the style will be changed to "MasterDocument.docx (master document)" as shown in the image below.
If you select [Yes] in the displayed dialog, the style name on the "GroupDocumentStyle.docx (sub-document)" side will be changed, and the style will be maintained as shown in the image below.
In Word API, unlinking sub-document allows you to incorporate sub documents into the master document of a group document for group document created in Microsoft Word described in above.
In Word API, you can perform the following two types of processing by specifying options for duplicate styles.
Member Variable | Descriptions |
---|---|
Ignore |
Discards duplicate styles on the sub-document side. Execution result is same as "Discard duplicate styles". |
Maintain |
Rename the style on the duplicate sub-document side to maintain the style. Execution result is same as "Maintaining duplicate styles". |
The figure below shows an example of the execution of what is described in this section.
[Install directory]/samples/templates/Unlink_sub-document.zip contains sample files for unlinking sub-documents.