Word加载项js-无法写入新文档

时间:2018-11-18 19:18:08

标签: office365 ms-office office-js office-addins word-addins

我正在尝试使用Office JS创建Word加载项,该加载项将查看当前打开的文档中的内容,然后创建一个新文档并写入此新文档。这是我要执行的操作的代码段:

            var myNewDoc = context.application.createDocument();
            context.load(myNewDoc);
            var body = myNewDoc.body;
            body.insertText('some text', Word.InsertLocation.end);

但是当我运行它时,出现以下错误:

Debug info: {"code":"NotAllowed","message":"The action isn’t supported in Word Online. Check the OfficeExtension.Error.debugInfo for more information.","errorLocation":"DocumentCreated.body","statement":"var body=createDocument.body;","surroundingStatements":["var v=Microsoft.WordServices.Application.newObject();","var createDocument=v.createDocument();","// Instantiate {createDocument}","// >>>>>","var body=createDocument.body;","// <<<<<","// Instantiate {body}"],"fullStatements":["Please enable config.extendedErrorLogging to see full statements."]}

是否正在写入不是当前活动文档的文档?我认为,如果允许我们创建一个新文档,那么我们应该能够对其进行写操作。

0 个答案:

没有答案