打开插件后无法编辑word文档

Cant edit worddocument after opening the addin

关于我之前的问题“Word 插件在 word online 上不起作用”我现在有一个插件,我可以在其中使用 ooxml 获取页眉和页脚,并且它们是在初始化过程中添加的 Office.initalize = function (原因)。

当我打开插件时,会添加页眉和页脚。当我然后尝试在主体中输入任何内容时,它只能在一行中输入。这只是Word online 上的一个问题。本地客户端 - 没问题。

还应该提到,如果您从 OneDrive 打开一个现有模板,然后打开插件,则在文档中输入文本没有问题。

不知道有没有其他人遇到过这个问题或类似的问题,你想出了什么解决办法?请查看前面的代码问题:“Word addin doesn't work on word online”

你的意思是AddFooter和AddHeader可以通过在打开插件的initialize方法中调用InsertOoxml API成功。但是打开插件后无法编辑文档正文

我认为主体中可能有一些不受支持的东西,就像类似问题的原因"Word addin doesn't work on word online."

你可以提供文档给我,我可以查证根本原因。

在Word.run

前添加'return'
function addHeader() {
    return Word.run(function (context) {

        var sections = context.document.sections;
        context.load(sections, 'body/style');

        return context.sync().then(function () {

            var header = sections.items[0].getHeader("primary");
            var templateHeader = getHeaderFooter('/xml/simrisHeader.xml');
            header.insertOoxml(templateHeader, Word.InsertLocation.replace);

            return context.sync().then(function () {
                console.log("Added a header to the first section.");
            });
        });
    })
    .catch(function (error) {

        console.log('Error: ' + JSON.stringify(error));
        if (error instanceof OfficeExtension.Error) {
            console.log('Debug info: ' + JSON.stringify(error.debugInfo));
        }
    });
}

使用以下样式调用 addFooter 和 addHeader:

addFooter().then(function() {
    addHeader();
};