0

Wordのアドインを開発するためにjavaScript APIを使用しています。サーバーからファイルを読み込み、文書、現在の.docxファイルが正常に動作し、文書に挿入されたが、私はドキュメントに.RTF形式のファイルの内容を挿入しようとすると、単語はエラーの下にスローされます:私は挿入するために、コードの下に使用していますWordのjavascript APIを使用してリッチテキスト形式(.rtf)のファイルコンテンツをword docに挿入する方法

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); 

RTF形式のファイルコンテンツを挿入する方法を教えてください単語の文書で。おかげさまで

+0

完全なコードスニペットを投稿できますか? –

+0

私はこれを研究しています。その間、RTFファイルは同等のdocxファイルよりもはるかに大きくなる傾向があり、タイミングの問題はcontext.sync()呼び出しの誤った取り扱いで逃れることができないかどうかに影響します。 insertFileFromBase64を呼び出すWord.runには、insertFileFromBase64の呼び出し後に "return context.sync()"があることを確認してください。キーワード "return"を忘れないでください。それはそこになければならない。 –

+0

@ RickKirkham-Microsoftありがとう、私はリターンを逃した。 – Amit

答えて

0

今日のAPIではRTFファイルの挿入はサポートされていません。docx形式を試してみてください。 あなたのエラーはあなたがreturn context.sync()を呼び出していないことが原因です。

+0

ありがとう、私はcontext.syncの前に戻り値が見つからなかった。 RTFを読み込んでRTFをDOCXに変換する方法はありますか?RTFファイルをどのように管理することができますか? – Amit

関連する問題