An Office service that supports add-ins to interact with objects in Office client applications.
Hi Emeba Njenga
As far as I know, Legacy tracked changes, especially in documents originating from .doc files or Compatibility Mode and leave behind internal revision structures that are not fully supported by Word add-ins. This places the document in an invalid or overly complex state, which commonly triggers Error 5001 when calling Document.insertHtml or ContentControl.insertHtml.
Link information: https://mms.heiai.top/en-us/office/dev/add-ins/reference/javascript-api-for-office-error-codes
Therefore, the most effective and reliable solution is to fully convert the document to a modern .docx format and clean up legacy tracked changes before inserting HTML. Kindly follow:
- Save the document as a fully converted
.docxfile (ensure it no longer opens in Compatibility Mode). - Accept or clean up existing tracked changes before performing the HTML insertion.
- After the document state is normalized, proceed with
insertHtml. Track Changes can be re-enabled afterward if needed.
Regards
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.