0

我正在使用 word javaScript Api 开发 Word 插件,我需要从服务器加载文件并将内容插入到文档中,当前 .docx 文件工作正常并插入到文档中,但是当我尝试插入 . rtf 格式文件内容写入文档,word 抛出以下错误:

Error: {"name":"OfficeExtension.Error","code":"RunMustReturnPromise","message":"The batch function passed to the \".run\" method didn't return a promise. The function must return a promise, so that any automatically-tracked objects can be released at the completion of the batch operation. Typically, you return a promise by returning the response from \"context.sync()\".","traceMessages":[],"debugInfo":{},"stack":"RunMustReturnPromise: The batch function passed to the \".run\" method didn't return a promise. The function must return a promise, so that any automatically-tracked objects can be released at the completion of the batch operation. Typically, you return a promise by returning the response from \"context.sync()\".\n   at t.throwError (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:233250)\n   at Anonymous function (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:202009)\n   at yi (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.0

我正在使用以下代码插入内容:

range.insertFileFromBase64(myBase64, Word.InsertLocation.start);

请建议我如何在 word 文档中插入 RTF 格式的文件内容。谢谢。

4

1 回答 1

0

目前 API 不支持插入 RTF 文件,请尝试使用 docx 格式。顺便说一句,您的错误似乎是您没有调用 return context.sync()。

于 2017-03-16T23:15:39.010 回答