我使用javaScript Api来开发Word加载项,我需要从服务器加载文件并将内容插入到文档中,目前.docx文件工作正常并插入到文档中但是当我尝试将.rtf格式的文件内容插入到文档中,单词抛出错误:
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格式文件内容。 感谢。
答案 0 :(得分:0)
今天的API不支持插入RTF文件,请尝试使用docx格式。 你的错误似乎是你没有调用return context.sync()。