Skip to Content
MosaicMosaicDocs
Tool Reference

EditWordDocument

Edit an uploaded Word (.docx) document in place: an ordered batch of operations applied atomically to its live copy, so everyone with it open sees the change at once, and nothing changes if any operation fails.

Starter documentation. Features and account details may differ from this deployment.

EditWordDocument

Edit an uploaded Word (.docx) document in place: an ordered batch of operations applied atomically to its live copy, so everyone with it open sees the change at once, and nothing changes if any operation fails. ReadWordDocument first and address paragraphs, tables and blocks by the ids it reports (they are not numbers). Use replaceText for wording changes (exact text within one paragraph; formatting is kept), setText to rewrite a whole paragraph, formatText for bold, italic, underline or strikethrough, insertParagraph to add paragraphs (each line of text becomes one; a style is optional), setStyle to change a paragraph style such as Heading1, delete to remove a paragraph, table or block, and addComment to add a Word comment on text. Only insertParagraph and addComment text may contain line breaks. Paragraphs inside table cells are edited the same way. Tracked changes (a redline): with trackChanges true, or when the document already tracks changes and trackChanges is omitted, edits are recorded as real Word revisions (insertions, deletions, formatting and style changes) that the counterparty can accept or reject in Word; pass trackChanges true whenever the user asks for a redline, tracked changes or a markup. Revisions and addComment comments are attributed to the requesting user by name, not to you; pass author only when the user names someone else (a firm or another person). addComment comments are saved in the file and travel with it to Word; use them for comments meant for whoever receives the document, and Comment or CommentOnText for discussion inside Mosaic. Returns the changed blocks as they now read, with the ids of new paragraphs; check them. At most 50 operations. To make a new Word document from an existing one (a contract filled in for a counterparty, a variant), DuplicateItem it and edit the copy. Never build a .docx file in code; EditDocument cannot edit Word documents.

Parameters

ParameterTypeRequiredDescription
documentIdstringYesWord document ID.
operationsWordDocumentOperation[]YesOrdered operations applied together.
trackChangesbooleanNoRecord the edits as tracked changes (true) or apply them directly (false). Omit to follow the document's own Track Changes setting.
authorstringNoName the tracked changes and comments are attributed to. Omit to use the requesting user's name.

On this page