我正在使用Word JavaScript API来开发Word add-in,我需要从服务器加载文件并将内容插入文档中,当前.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格式文件内容。谢谢。
今天不支持插入RTF文件,请尝试DOCX格式。顺便说一句,您的错误似乎是您没有调用return contect.sync()。