execute_wordjs
Execute Office.js code in a live Word document to read or edit paragraphs, tables, searches, and tracked changes, then return results after syncing context.
Instructions
Execute arbitrary Office.js code inside the live Word document. The code runs inside Word.run(async (context) => { ... }) with 'context' available as a variable. Use 'await context.sync()' after loading properties. Return a value to get it back as the tool result. Common operations: read the body (context.document.body), insert paragraphs, search and replace, work with tables, read tracked changes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Office.js code to execute. Runs inside Word.run() with 'context' available. Use 'return' to send back a result. | |
| documentId | No | Target document ID from list_documents. Optional when only one document is connected. |