Word insertOoxml method returning Error: Unknown for all input

Word insertOoxml method returning Error: Unknown for all input



I have an existing Word Add-In solution that has been working well for a long time that now cannot insert OOXML content into Word documents. Trying to break this down I can't get the insertOoxml method to work under any circumstance.



To reproduce:


await Word.run(async (context) =>
context.document.getSelection().insertOoxml(theOoxml, 'Start');
await context.sync();
);



Where theOoxml can be any valid Ooxml string. The reference example I have been using is:


<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
<pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512">
<pkg:xmlData>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" />
</Relationships>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:name="/word/document.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml">
<pkg:xmlData>
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid wp14">
<w:body>
<w:p>
<w:r>
<w:t>
Hey there
</w:t>
</w:r>
</w:p>
</w:body>
</w:document>
</pkg:xmlData>
</pkg:part>
</pkg:package>



But have also tried other reference examples: https://docs.microsoft.com/en-us/office/dev/add-ins/word/create-better-add-ins-for-word-with-office-open-xml



Results in:



word-web-16.00.debug.js:11162 Uncaught (in promise) Error: unknown
at new RuntimeError (word-web-16.00.debug.js:11162)
at RequestContext.ClientRequestContext.processRequestExecutorResponseMessage (word-web-16.00.debug.js:13713)
at word-web-16.00.debug.js:13620



Have tried it in different tenants, browsers, and this is driving me a bit bonkers. If this does work for you please let me know your general config/setup.



Thanks.



UPDATE:



To avoid questions about the validity of the XML itself, the following code gets the OOXML for the current selection and then duplicates it after the selection - also fails with the same error.


await Word.run(async (context) =>

var sourceRange = context.document.getSelection();
var contentToCopy = sourceRange.getOoxml();
await context.sync();

sourceRange.insertOoxml(contentToCopy.value, 'After');
await context.sync();
);



Hopefully there is something simple I am missing here. Any suggestions/workarounds for inserting any Ooxml fragment appreciated.



UPDATE 2018-09-04:
Microsoft have acknowledged the issue and are going to fix it.



UPDATE 2018-09-12:
InsertOoxml appears to be working again - although I have not had a confirmation from Microsoft regarding the fix.






I tried your xml on word desktop, it also can't insert anything. So I suspect the xml is invalid. So can you first try to call range.getOoxml() and take a look at the valid ooxml and then use that ooxml to call range.insertOoxml() API?

– MSFT-Jipyua
Aug 30 '18 at 9:27






This is invalide Word Open XML: <w:p>Hey there</w:p> It's missing the <w:r><w:t> elements around the text that should appear. Type the text in a Word document then view the XML in the Open XML SDK Productivity Tool and you'll see what I mean...

– Cindy Meister
Aug 30 '18 at 10:28



<w:p>Hey there</w:p>


<w:r><w:t>






Encountering the same issue trying to replace body OoXML on the page, even with basic examples. e.g. setting the body OoXML back to itself throws the same error even though the OoXML is the value given from querying context.document.body.getOoXml() and setting the value back on insertOoXml(value)

– Hitmands
Aug 30 '18 at 12:23



context.document.body.getOoXml()


value


insertOoXml(value)






@Hitmands thanks for confirming, I thought I was losing my mind. I will investigate the possibility of opening a Microsoft support case for this - but i'm not hopeful.

– James Boman
Aug 31 '18 at 4:26






@Peak My support case with Microsoft has been escalated - they acknowledged the issue and are going to fix it.

– James Boman
Sep 4 '18 at 7:50




1 Answer
1



InsertOoxml appears to be working again now as it was before.



I have not yet had a conformation from the Microsoft support case regarding the fix, but all my customers appears to be functioning again.



Thanks to Juan Balmori and those working on the extensibility team for getting this fixed up.



J.






yes the fix was shipped. tanks for confirming.

– Juan Balmori
Oct 3 '18 at 21:29



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ