Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Word InsertoXML方法返回错误:对于所有输入未知_Javascript_Ms Word_Office Js_Office Addins_Word Addins - Fatal编程技术网

Javascript Word InsertoXML方法返回错误:对于所有输入未知

Javascript Word InsertoXML方法返回错误:对于所有输入未知,javascript,ms-word,office-js,office-addins,word-addins,Javascript,Ms Word,Office Js,Office Addins,Word Addins,我有一个现有的Word插件解决方案,它已经运行了很长时间,现在无法将OOXML内容插入到Word文档中。为了解决这个问题,我无法让InsertOXML方法在任何情况下工作 复制: await Word.run(async (context) => { context.document.getSelection().insertOoxml(theOoxml, 'Start'); await context.sync();

我有一个现有的Word插件解决方案,它已经运行了很长时间,现在无法将OOXML内容插入到Word文档中。为了解决这个问题,我无法让InsertOXML方法在任何情况下工作

复制:

        await Word.run(async (context) => {
            context.document.getSelection().insertOoxml(theOoxml, 'Start');
            await context.sync();
        });
其中,OXML可以是任何有效的Ooxml字符串。我使用的参考示例是:

<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>
希望我在这里遗漏了一些简单的东西。对于插入AnyOoxml片段的任何建议/解决方法,我们都将不胜感激

更新2018-09-04: 微软已经承认了这个问题,并将解决它

更新2018-09-12:
InsertoXML似乎又开始工作了-尽管我还没有得到Microsoft关于修复的确认。

InsertoXML现在似乎又像以前一样工作了

我还没有从Microsoft支持案例中得到关于修复的确认,但我的所有客户似乎都恢复了功能

感谢和扩展性团队的工作人员修复了这个问题


J.

这是无效的Word Open XML:
嘿,这里
它缺少文本周围应该出现的
元素。在Word文档中键入文本,然后在OpenXMLSDK生产力工具中查看XML,您将看到我的意思……在尝试替换页面上的正文OoXML时遇到相同的问题,即使是使用基本示例。e、 g.将正文OoXML设置回自身会引发相同的错误,即使OoXML是查询
context.document.body.getOoXml()
并将
值设置回
insertOoXml(value)
@Hitmands时给出的值。谢谢您的确认,我以为我疯了。我将调查是否有可能为此打开Microsoft支持案例-但我不抱希望。@Peak我与Microsoft的支持案例已升级-他们已确认问题并将解决它。大家好。最新消息是,我们正在积极进行Sev1升级以解决此问题。完成后,我们会通知您。对于给您带来的不便,我们深表歉意。
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();
});