Ms word 如何使用word javascript API将富文本格式(.rtf)文件内容插入word文档

Ms word 如何使用word javascript API将富文本格式(.rtf)文件内容插入word文档,ms-word,office365,office-js,word-addins,javascript-api-for-office,Ms Word,Office365,Office Js,Word Addins,Javascript Api For Office,我正在使用word javaScript Api开发word加载项,我需要从服务器加载一个文件并将内容插入到文档中,目前。docx文件工作正常并插入到文档中,但当我尝试将.rtf格式的文件内容插入到文档中时,word抛出以下错误: Error: {"name":"OfficeExtension.Error","code":"RunMustReturnPromise","message":"The batch function passed to the \".run\" method didn'

我正在使用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格式文件内容。
谢谢。

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

您能发布完整的代码片段吗?我正在研究这个问题。同时,RTF文件往往比等效的docx文件大得多,并且计时问题可能会影响您是否能够避免错误处理context.sync()调用。确保调用insertFileFromBase64的Word.run在调用insertFileFromBase64之后的某个地方有一个“return context.sync()”。别忘了关键字“return”。它必须在那里。@RickKirkham Microsoft谢谢,我错过了退货。谢谢,我错过了context.sync之前的退货。有没有办法读取RTF并将RTF转换为DOCX,或者有什么建议可以帮助我管理RTF文件?