My task is to place a comment via Office Javascript API in a Word document (.docx) compatible to Word 2007 or later.
I found, that there is no direct way to do this via Microsoft API.
Since I am able to pass OOXML to the Word document, I thought that I can use this to place a comment.
I did some research on the Word document structure and found, that comments are stored in a separate XML file called "comments.xml" and then referenced via an ID in the "document.xml" (I attached a corresponding sample).
Is there a way to edit this comments.xml
via API in order to place comments in the Word document or is this not possible?
Sample "document.xml":
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
mc:Ignorable="w14 wp14">
<w:body>
<w:p w:rsidR="00A9590C" w:rsidRDefault="0058668B">
<w:r>
<w:t>I am text.</w:t>
</w:r>
</w:p>
<w:p w:rsidR="0058668B" w:rsidRDefault="0058668B">
<w:commentRangeStart w:id="0"/>
<w:r>
<w:t>I am text with comment.</w:t>
</w:r>
<w:commentRangeEnd w:id="0"/>
<w:r>
<w:rPr>
<w:rStyle w:val="Kommentarzeichen"/>
</w:rPr>
<w:commentReference w:id="0"/>
</w:r>
</w:p>
<w:sectPr w:rsidR="0058668B">
<w:pgSz w:w="11906" w:h="16838"/>
<w:pgMar w:top="1417" w:right="1417" w:bottom="1134" w:left="1417" w:header="708" w:footer="708"
w:gutter="0"/>
<w:cols w:space="708"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:body>
Sample "comments.xml":
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:comments
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
mc:Ignorable="w14 wp14">
<w:comment w:id="0" w:author="rz" w:date="2015-05-23T10:30:00Z" w:initials="r">
<w:p w:rsidR="0058668B" w:rsidRDefault="0058668B">
<w:pPr>
<w:pStyle w:val="Kommentartext"/>
</w:pPr>
<w:r>
<w:rPr>
<w:rStyle w:val="Kommentarzeichen"/>
</w:rPr>
<w:annotationRef/>
</w:r>
<w:r>
<w:t>Test</w:t>
</w:r>
<w:bookmarkStart w:id="1" w:name="_GoBack"/>
<w:bookmarkEnd w:id="1"/>
</w:p>
</w:comment>
</w:comments>