What's new in Word JavaScript API 1.4
WordApi 1.4 added support for bookmarks, change tracking, comments, custom XML parts, fields, and merging and splitting table cells.
API list
The following table lists the APIs in Word JavaScript API requirement set 1.4. To view API reference documentation for all APIs supported by Word JavaScript API requirement set 1.4 or earlier, see Word APIs in requirement set 1.4 or earlier.
Class | Fields | Description |
---|---|---|
Body | fields | Gets the collection of field objects in the body. |
getComments() | Gets comments associated with the body. | |
getReviewedText(changeTrackingVersion?: Word.ChangeTrackingVersion) | Gets reviewed text based on ChangeTrackingVersion selection. | |
Comment | authorEmail | Gets the email of the comment's author. |
authorName | Gets the name of the comment's author. | |
content | Specifies the comment's content as plain text. | |
contentRange | Specifies the comment's content range. | |
creationDate | Gets the creation date of the comment. | |
delete() | Deletes the comment and its replies. | |
getRange() | Gets the range in the main document where the comment is on. | |
id | Gets the ID of the comment. | |
replies | Gets the collection of reply objects associated with the comment. | |
reply(replyText: string) | Adds a new reply to the end of the comment thread. | |
resolved | Specifies the comment thread's status. | |
CommentCollection | getFirst() | Gets the first comment in the collection. |
getFirstOrNullObject() | Gets the first comment in the collection. | |
items | Gets the loaded child items in this collection. | |
CommentContentRange | bold | Specifies a value that indicates whether the comment text is bold. |
hyperlink | Gets the first hyperlink in the range, or sets a hyperlink on the range. | |
insertText(text: string, insertLocation: Word.InsertLocation | "Replace" | "Start" | "End" | "Before" | "After") | Inserts text into at the specified location. | |
isEmpty | Checks whether the range length is zero. | |
italic | Specifies a value that indicates whether the comment text is italicized. | |
strikeThrough | Specifies a value that indicates whether the comment text has a strikethrough. | |
text | Gets the text of the comment range. | |
underline | Specifies a value that indicates the comment text's underline type. | |
CommentReply | authorEmail | Gets the email of the comment reply's author. |
authorName | Gets the name of the comment reply's author. | |
content | Specifies the comment reply's content. | |
contentRange | Specifies the commentReply's content range. | |
creationDate | Gets the creation date of the comment reply. | |
delete() | Deletes the comment reply. | |
id | Gets the ID of the comment reply. | |
parentComment | Gets the parent comment of this reply. | |
CommentReplyCollection | getFirst() | Gets the first comment reply in the collection. |
getFirstOrNullObject() | Gets the first comment reply in the collection. | |
items | Gets the loaded child items in this collection. | |
ContentControl | fields | Gets the collection of field objects in the content control. |
getComments() | Gets comments associated with the content control. | |
getReviewedText(changeTrackingVersion?: Word.ChangeTrackingVersion) | Gets reviewed text based on ChangeTrackingVersion selection. | |
CustomXmlPart | delete() | Deletes the custom XML part. |
deleteAttribute(xpath: string, namespaceMappings: { [key: string]: string }, name: string) | Deletes an attribute with the given name from the element identified by xpath. | |
deleteElement(xpath: string, namespaceMappings: { [key: string]: string }) | Deletes the element identified by xpath. | |
getXml() | Gets the full XML content of the custom XML part. | |
id | Gets the ID of the custom XML part. | |
insertAttribute(xpath: string, namespaceMappings: { [key: string]: string }, name: string, value: string) | Inserts an attribute with the given name and value to the element identified by xpath. | |
insertElement(xpath: string, xml: string, namespaceMappings: { [key: string]: string }, index?: number) | Inserts the given XML under the parent element identified by xpath at child position index. | |
namespaceUri | Gets the namespace URI of the custom XML part. | |
query(xpath: string, namespaceMappings: { [key: string]: string }) | Queries the XML content of the custom XML part. | |
setXml(xml: string) | Sets the full XML content of the custom XML part. | |
updateAttribute(xpath: string, namespaceMappings: { [key: string]: string }, name: string, value: string) | Updates the value of an attribute with the given name of the element identified by xpath. | |
updateElement(xpath: string, xml: string, namespaceMappings: { [key: string]: string }) | Updates the XML of the element identified by xpath. | |
CustomXmlPartCollection | add(xml: string) | Adds a new custom XML part to the document. |
getByNamespace(namespaceUri: string) | Gets a new scoped collection of custom XML parts whose namespaces match the given namespace. | |
getCount() | Gets the number of items in the collection. | |
getItem(id: string) | Gets a custom XML part based on its ID. | |
getItemOrNullObject(id: string) | Gets a custom XML part based on its ID. | |
items | Gets the loaded child items in this collection. | |
CustomXmlPartScopedCollection | getCount() | Gets the number of items in the collection. |
getItem(id: string) | Gets a custom XML part based on its ID. | |
getItemOrNullObject(id: string) | Gets a custom XML part based on its ID. | |
getOnlyItem() | If the collection contains exactly one item, this method returns it. | |
getOnlyItemOrNullObject() | If the collection contains exactly one item, this method returns it. | |
items | Gets the loaded child items in this collection. | |
Document | changeTrackingMode | Specifies the ChangeTracking mode. |
customXmlParts | Gets the custom XML parts in the document. | |
deleteBookmark(name: string) | Deletes a bookmark, if it exists, from the document. | |
getBookmarkRange(name: string) | Gets a bookmark's range. | |
getBookmarkRangeOrNullObject(name: string) | Gets a bookmark's range. | |
settings | Gets the add-in's settings in the document. | |
Field | code | Specifies the field's code instruction. |
getNext() | Gets the next field. | |
getNextOrNullObject() | Gets the next field. | |
parentBody | Gets the parent body of the field. | |
parentContentControl | Gets the content control that contains the field. | |
parentContentControlOrNullObject | Gets the content control that contains the field. | |
parentTable | Gets the table that contains the field. | |
parentTableCell | Gets the table cell that contains the field. | |
parentTableCellOrNullObject | Gets the table cell that contains the field. | |
parentTableOrNullObject | Gets the table that contains the field. | |
result | Gets the field's result data. | |
FieldCollection | getFirst() | Gets the first field in this collection. |
getFirstOrNullObject() | Gets the first field in this collection. | |
items | Gets the loaded child items in this collection. | |
Paragraph | fields | Gets the collection of fields in the paragraph. |
getComments() | Gets comments associated with the paragraph. | |
getReviewedText(changeTrackingVersion?: Word.ChangeTrackingVersion) | Gets reviewed text based on ChangeTrackingVersion selection. | |
Range | fields | Gets the collection of field objects in the range. |
getBookmarks(includeHidden?: boolean, includeAdjacent?: boolean) | Gets the names all bookmarks in or overlapping the range. | |
getComments() | Gets comments associated with the range. | |
getReviewedText(changeTrackingVersion?: Word.ChangeTrackingVersion) | Gets reviewed text based on ChangeTrackingVersion selection. | |
insertBookmark(name: string) | Inserts a bookmark on the range. | |
insertComment(commentText: string) | Insert a comment on the range. | |
Setting | delete() | Deletes the setting. |
key | Gets the key of the setting. | |
value | Specifies the value of the setting. | |
SettingCollection | add(key: string, value: any) | Creates a new setting or sets an existing setting. |
deleteAll() | Deletes all settings in this add-in. | |
getCount() | Gets the count of settings. | |
getItem(key: string) | Gets a setting object by its key, which is case-sensitive. | |
getItemOrNullObject(key: string) | Gets a setting object by its key, which is case-sensitive. | |
items | Gets the loaded child items in this collection. | |
Table | fields | Gets the collection of field objects in the table. |
mergeCells(topRow: number, firstCell: number, bottomRow: number, lastCell: number) | Merges the cells bounded inclusively by a first and last cell. | |
TableCell | split(rowCount: number, columnCount: number) | Splits the cell into the specified number of rows and columns. |
TableRow | fields | Gets the collection of field objects in the table row. |
merge() | Merges the row into one cell. |
See also
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Office Add-ins