OpenXmlPart.getPartByRelationshipType (relationshipType)

Return to the
Open XML SDK for JavaScript
Developer Center
Gets the part with the specified relationship type. If there is more than one part with the specified relationship type, this function returns the first one. openXml.relationshipTypes contains a list of the most common relationship types.

Syntax

    var part = OpenXmlPart.getPartByRelationshipType(relationshipType);

Arguments

    relationshipType: An string that contains the relationship type.

Return Value

    Returns an OpenXmlPart object. If there is no part related with the specified relationship type, this function returns null.

Usage

    var commentsPart = doc.mainDocumentPart()
    .getPartByRelationshipType(openXml.relationshipTypes.wordprocessingComments);

Example

// Open a document that contains comments.
var doc = new openXml.OpenXmlPackage(withComments_flatOpc);
var commentsPart = doc
    .mainDocumentPart()
    .getPartByRelationshipType(openXml.relationshipTypes.wordprocessingComments);
// Note that there are convenience functions that retrieve the most commonly used parts.
var commentsPart2 = doc.mainDocumentPart().wordprocessingCommentsPart();
var o = [];
if (commentsPart !== null) {
    o.push("Found the part, uri = " + commentsPart.uri);
}
if (commentsPart2 !== null) {
    o.push("Also found uri = " + commentsPart2.uri);
}
return { output: o };