word package

Classes

Word.Body

Represents the body of a document or a section.

Word.ContentControl

Represents a content control. Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. Individual content controls may contain contents such as images, tables, or paragraphs of formatted text. Currently, only rich text content controls are supported.

Word.ContentControlCollection

Contains a collection of Word.ContentControl objects. Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. Individual content controls may contain contents such as images, tables, or paragraphs of formatted text. Currently, only rich text content controls are supported.

Word.Document

The Document object is the top level object. A Document object contains one or more sections, content controls, and the body that contains the contents of the document.

Word.Font

Represents a font.

Word.InlinePicture

Represents an inline picture.

Word.InlinePictureCollection

Contains a collection of Word.InlinePicture objects.

Word.Paragraph

Represents a single paragraph in a selection, range, content control, or document body.

Word.ParagraphCollection

Contains a collection of Word.Paragraph objects.

Word.Range

Represents a contiguous area in a document.

Word.RangeCollection

Contains a collection of Word.Range objects.

Word.RequestContext

The RequestContext object facilitates requests to the Word application. Since the Office add-in and the Word application run in two different processes, the request context is required to get access to the Word object model from the add-in.

Word.SearchOptions

Specifies the options to be included in a search operation.

To learn more about how to use search options in the Word JavaScript APIs, read Use search options to find text in your Word add-in.

Word.Section

Represents a section in a Word document.

Word.SectionCollection

Contains the collection of the document's Word.Section objects.

Interfaces

Word.Interfaces.BodyData

An interface describing the data returned by calling body.toJSON().

Word.Interfaces.BodyLoadOptions

Represents the body of a document or a section.

Word.Interfaces.BodyUpdateData

An interface for updating data on the Body object, for use in body.set({ ... }).

Word.Interfaces.CollectionLoadOptions

Provides ways to load properties of only a subset of members of a collection.

Word.Interfaces.ContentControlCollectionData

An interface describing the data returned by calling contentControlCollection.toJSON().

Word.Interfaces.ContentControlCollectionLoadOptions

Contains a collection of Word.ContentControl objects. Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. Individual content controls may contain contents such as images, tables, or paragraphs of formatted text. Currently, only rich text content controls are supported.

Word.Interfaces.ContentControlCollectionUpdateData

An interface for updating data on the ContentControlCollection object, for use in contentControlCollection.set({ ... }).

Word.Interfaces.ContentControlData

An interface describing the data returned by calling contentControl.toJSON().

Word.Interfaces.ContentControlLoadOptions

Represents a content control. Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. Individual content controls may contain contents such as images, tables, or paragraphs of formatted text. Currently, only rich text content controls are supported.

Word.Interfaces.ContentControlUpdateData

An interface for updating data on the ContentControl object, for use in contentControl.set({ ... }).

Word.Interfaces.CustomPropertyCollectionData

An interface describing the data returned by calling customPropertyCollection.toJSON().

Word.Interfaces.CustomPropertyCollectionUpdateData

An interface for updating data on the CustomPropertyCollection object, for use in customPropertyCollection.set({ ... }).

Word.Interfaces.CustomPropertyData

An interface describing the data returned by calling customProperty.toJSON().

Word.Interfaces.CustomPropertyUpdateData

An interface for updating data on the CustomProperty object, for use in customProperty.set({ ... }).

Word.Interfaces.DocumentCreatedData

An interface describing the data returned by calling documentCreated.toJSON().

Word.Interfaces.DocumentCreatedUpdateData

An interface for updating data on the DocumentCreated object, for use in documentCreated.set({ ... }).

Word.Interfaces.DocumentData

An interface describing the data returned by calling document.toJSON().

Word.Interfaces.DocumentLoadOptions

The Document object is the top level object. A Document object contains one or more sections, content controls, and the body that contains the contents of the document.

Word.Interfaces.DocumentPropertiesData

An interface describing the data returned by calling documentProperties.toJSON().

Word.Interfaces.DocumentPropertiesUpdateData

An interface for updating data on the DocumentProperties object, for use in documentProperties.set({ ... }).

Word.Interfaces.DocumentUpdateData

An interface for updating data on the Document object, for use in document.set({ ... }).

Word.Interfaces.FontData

An interface describing the data returned by calling font.toJSON().

Word.Interfaces.FontLoadOptions

Represents a font.

Word.Interfaces.FontUpdateData

An interface for updating data on the Font object, for use in font.set({ ... }).

Word.Interfaces.InlinePictureCollectionData

An interface describing the data returned by calling inlinePictureCollection.toJSON().

Word.Interfaces.InlinePictureCollectionLoadOptions

Contains a collection of Word.InlinePicture objects.

Word.Interfaces.InlinePictureCollectionUpdateData

An interface for updating data on the InlinePictureCollection object, for use in inlinePictureCollection.set({ ... }).

Word.Interfaces.InlinePictureData

An interface describing the data returned by calling inlinePicture.toJSON().

Word.Interfaces.InlinePictureLoadOptions

Represents an inline picture.

Word.Interfaces.InlinePictureUpdateData

An interface for updating data on the InlinePicture object, for use in inlinePicture.set({ ... }).

Word.Interfaces.ListCollectionData

An interface describing the data returned by calling listCollection.toJSON().

Word.Interfaces.ListCollectionUpdateData

An interface for updating data on the ListCollection object, for use in listCollection.set({ ... }).

Word.Interfaces.ListData

An interface describing the data returned by calling list.toJSON().

Word.Interfaces.ListItemData

An interface describing the data returned by calling listItem.toJSON().

Word.Interfaces.ListItemUpdateData

An interface for updating data on the ListItem object, for use in listItem.set({ ... }).

Word.Interfaces.ParagraphCollectionData

An interface describing the data returned by calling paragraphCollection.toJSON().

Word.Interfaces.ParagraphCollectionLoadOptions

Contains a collection of Word.Paragraph objects.

Word.Interfaces.ParagraphCollectionUpdateData

An interface for updating data on the ParagraphCollection object, for use in paragraphCollection.set({ ... }).

Word.Interfaces.ParagraphData

An interface describing the data returned by calling paragraph.toJSON().

Word.Interfaces.ParagraphLoadOptions

Represents a single paragraph in a selection, range, content control, or document body.

Word.Interfaces.ParagraphUpdateData

An interface for updating data on the Paragraph object, for use in paragraph.set({ ... }).

Word.Interfaces.RangeCollectionData

An interface describing the data returned by calling rangeCollection.toJSON().

Word.Interfaces.RangeCollectionLoadOptions

Contains a collection of Word.Range objects.

Word.Interfaces.RangeCollectionUpdateData

An interface for updating data on the RangeCollection object, for use in rangeCollection.set({ ... }).

Word.Interfaces.RangeData

An interface describing the data returned by calling range.toJSON().

Word.Interfaces.RangeLoadOptions

Represents a contiguous area in a document.

Word.Interfaces.RangeUpdateData

An interface for updating data on the Range object, for use in range.set({ ... }).

Word.Interfaces.SearchOptionsData

An interface describing the data returned by calling searchOptions.toJSON().

Word.Interfaces.SearchOptionsLoadOptions

Specifies the options to be included in a search operation.

Word.Interfaces.SearchOptionsUpdateData

An interface for updating data on the SearchOptions object, for use in searchOptions.set({ ... }).

Word.Interfaces.SectionCollectionData

An interface describing the data returned by calling sectionCollection.toJSON().

Word.Interfaces.SectionCollectionLoadOptions

Contains the collection of the document's Word.Section objects.

Word.Interfaces.SectionCollectionUpdateData

An interface for updating data on the SectionCollection object, for use in sectionCollection.set({ ... }).

Word.Interfaces.SectionData

An interface describing the data returned by calling section.toJSON().

Word.Interfaces.SectionLoadOptions

Represents a section in a Word document.

Word.Interfaces.SectionUpdateData

An interface for updating data on the Section object, for use in section.set({ ... }).

Word.Interfaces.TableBorderData

An interface describing the data returned by calling tableBorder.toJSON().

Word.Interfaces.TableBorderUpdateData

An interface for updating data on the TableBorder object, for use in tableBorder.set({ ... }).

Word.Interfaces.TableCellCollectionData

An interface describing the data returned by calling tableCellCollection.toJSON().

Word.Interfaces.TableCellCollectionUpdateData

An interface for updating data on the TableCellCollection object, for use in tableCellCollection.set({ ... }).

Word.Interfaces.TableCellData

An interface describing the data returned by calling tableCell.toJSON().

Word.Interfaces.TableCellUpdateData

An interface for updating data on the TableCell object, for use in tableCell.set({ ... }).

Word.Interfaces.TableCollectionData

An interface describing the data returned by calling tableCollection.toJSON().

Word.Interfaces.TableCollectionUpdateData

An interface for updating data on the TableCollection object, for use in tableCollection.set({ ... }).

Word.Interfaces.TableData

An interface describing the data returned by calling table.toJSON().

Word.Interfaces.TableRowCollectionData

An interface describing the data returned by calling tableRowCollection.toJSON().

Word.Interfaces.TableRowCollectionUpdateData

An interface for updating data on the TableRowCollection object, for use in tableRowCollection.set({ ... }).

Word.Interfaces.TableRowData

An interface describing the data returned by calling tableRow.toJSON().

Word.Interfaces.TableRowUpdateData

An interface for updating data on the TableRow object, for use in tableRow.set({ ... }).

Word.Interfaces.TableUpdateData

An interface for updating data on the Table object, for use in table.set({ ... }).

Enums

Word.Alignment
Word.BodyType
Word.BorderLocation
Word.BorderType
Word.BreakType

Specifies the form of a break.

Word.CellPaddingLocation
Word.ContentControlAppearance

ContentControl appearance

Word.ContentControlType

Specifies supported content control types and subtypes.

Word.DocumentPropertyType
Word.ErrorCodes
Word.EventType

Provides information about the type of a raised event. For each object type, please keep the order of: deleted, selection changed, data changed, added.

Word.FileContentFormat
Word.HeaderFooterType
Word.ImageFormat
Word.InsertLocation

The insertion location types.

Word.ListBullet
Word.ListLevelType
Word.ListNumbering
Word.LocationRelation
Word.RangeLocation
Word.SelectionMode

This enum sets where the cursor (insertion point) in the document is after a selection.

Word.Style
Word.TapObjectType
Word.UnderlineType

The supported styles for underline format.

Word.VerticalAlignment

Functions

Word.run(objects, batch)

Executes a batch script that performs actions on the Word object model, using the RequestContext of previously created API objects.

Word.run(object, batch)

Executes a batch script that performs actions on the Word object model, using the RequestContext of a previously created API object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released.

Word.run(batch)

Executes a batch script that performs actions on the Word object model, using a new RequestContext. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released.

Function Details

Word.run(objects, batch)

Executes a batch script that performs actions on the Word object model, using the RequestContext of previously created API objects.

export function run<T>(objects: OfficeExtension.ClientObject[], batch: (context: Word.RequestContext) => Promise<T>): Promise<T>;

Parameters

objects

OfficeExtension.ClientObject[]

An array of previously created API objects. The array will be validated to make sure that all of the objects share the same context. The batch will use this shared RequestContext, which means that any changes applied to these objects will be picked up by "context.sync()".

batch

(context: Word.RequestContext) => Promise<T>

A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Word application. Since the Office add-in and the Word application run in two different processes, the RequestContext is required to get access to the Word object model from the add-in.

Returns

Promise<T>

Word.run(object, batch)

Executes a batch script that performs actions on the Word object model, using the RequestContext of a previously created API object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released.

export function run<T>(object: OfficeExtension.ClientObject, batch: (context: Word.RequestContext) => Promise<T>): Promise<T>;

Parameters

object
OfficeExtension.ClientObject

A previously created API object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by "context.sync()".

batch

(context: Word.RequestContext) => Promise<T>

A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Word application. Since the Office add-in and the Word application run in two different processes, the RequestContext is required to get access to the Word object model from the add-in.

Returns

Promise<T>

Word.run(batch)

Executes a batch script that performs actions on the Word object model, using a new RequestContext. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released.

export function run<T>(batch: (context: Word.RequestContext) => Promise<T>): Promise<T>;

Parameters

batch

(context: Word.RequestContext) => Promise<T>

A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Word application. Since the Office add-in and the Word application run in two different processes, the RequestContext is required to get access to the Word object model from the add-in.

Returns

Promise<T>