我如何添加或更新页眉和页脚owa 365单词加载项的形状

问题描述

在OWA 365单词插件中遇到挑战或问题时,我想使用office.js API更改页眉和页脚OWA 365单词插件的形状。

我写的代码无法用Ooxml正确替换标题形状:-

带有Ooxml的代码:-https://docs.google.com/document/d/17SpDuJElkUash0359oqa7zA6CebxEhn14o3S4sN3w9s/edit?usp=sharing

function SubmitWord() {
            jQuery.when(ClearedWordDocument()).done(function (a1) {
                // Run a batch operation against the Word object model.
                Word.run(function (context) {
                    //showSelection();
                    var colorForCategory = "blue";              
                    var valClassification = "Confidential";
                    AddCustomWordProperty(context,valClassification);
                    var mySections = context.document.sections;
                    context.load(mySections);
                    return context.sync().then(function () {
                        var myHeader = mySections.items[0].getHeader("primary");
                      
                        return context.sync().then(function () {
    
                                var headerXML = "Here i am passsing valid ooxml for shape in header";
    
                                myHeader.insertOoxml(headerXML,Word.InsertLocation.replace);
    
                            var thisDocument = context.document;
                            return context.sync().then(function () {
                                jQuery("#spnNotification").text("Document klassified as " + valClassification + " & header will be viewed in Reading mode");
                                console.log("Added a header to the first section.");
                                context.load(thisDocument,'saved');
                                return context.sync().then(function () {
                                    if (thisDocument.saved === false) {
                                        thisDocument.save();
                                        return context.sync().then(function () {
                                            jQuery("#spnNotification").append('</br>document saved successfully ' + statusWord);
                                            console.log('Saved the document');
                                        });
                                    } else {
                                        
        jQuery("#spnNotification").append('</br>The document has not changed since the last save.')
                                        console.log('The document has not changed since the last save.');
                                    }
                                });
                            });
                        });
                    });
                }).catch(function (error) {
                    console.log('error: ' + JSON.stringify(error));
                }
                );
            });
}

以上代码始终可以在Word文档中插入形状,但是我想用在代码内部编写的此代码行替换形状

myHeader.insertOoxml(headerXML, Word.InsertLocation.replace

我想使用offic.js api对owa 365单词加载项执行添加/更新操作。如果不存在形状,则应插入形状,否则替换形状。

如果有人对带有office.js打开xml的owa 365 word加载项具有专业知识,请回复

带有Ooxml的代码:-https://docs.google.com/document/d/17SpDuJElkUash0359oqa7zA6CebxEhn14o3S4sN3w9s/edit?usp=sharing

Here insertion work perfectly but not updating the shape just overlapping the shape which is shown in image shared link

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)