Word.List class

Contains a collection of Word.Paragraph objects.

[ API set: WordApi 1.3 ]

Extends
OfficeExtension.ClientObject

Properties

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

id

Gets the list's id.

[ API set: WordApi 1.3 ]

levelExistences

Checks whether each of the 9 levels exists in the list. A true value indicates the level exists, which means there is at least one list item at that level. Read-only.

[ API set: WordApi 1.3 ]

levelTypes

Gets all 9 level types in the list. Each type can be 'Bullet', 'Number', or 'Picture'. Read-only.

[ API set: WordApi 1.3 ]

paragraphs

Gets paragraphs in the list. Read-only.

[ API set: WordApi 1.3 ]

Methods

getLevelFont(level)

Gets the font of the bullet, number, or picture at the specified level in the list.

[ API set: WordApi BETA (PREVIEW ONLY) ]

getLevelParagraphs(level)

Gets the paragraphs that occur at the specified level in the list.

[ API set: WordApi 1.3 ]

getLevelPicture(level)

Gets the base64 encoded string representation of the picture at the specified level in the list.

[ API set: WordApi BETA (PREVIEW ONLY) ]

getLevelString(level)

Gets the bullet, number, or picture at the specified level as a string.

[ API set: WordApi 1.3 ]

insertParagraph(paragraphText, insertLocation)

Inserts a paragraph at the specified location.

[ API set: WordApi 1.3 ]

insertParagraph(paragraphText, insertLocationString)

Inserts a paragraph at the specified location.

[ API set: WordApi 1.3 ]

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

resetLevelFont(level, resetFontName)

Resets the font of the bullet, number, or picture at the specified level in the list.

[ API set: WordApi BETA (PREVIEW ONLY) ]

setLevelAlignment(level, alignment)

Sets the alignment of the bullet, number, or picture at the specified level in the list.

[ API set: WordApi 1.3 ]

setLevelAlignment(level, alignmentString)

Sets the alignment of the bullet, number, or picture at the specified level in the list.

[ API set: WordApi 1.3 ]

setLevelBullet(level, listBullet, charCode, fontName)

Sets the bullet format at the specified level in the list. If the bullet is 'Custom', the charCode is required.

[ API set: WordApi 1.3 ]

setLevelBullet(level, listBulletString, charCode, fontName)

Sets the bullet format at the specified level in the list. If the bullet is 'Custom', the charCode is required.

[ API set: WordApi 1.3 ]

setLevelIndents(level, textIndent, bulletNumberPictureIndent)

Sets the two indents of the specified level in the list.

[ API set: WordApi 1.3 ]

setLevelNumbering(level, listNumbering, formatString)

Sets the numbering format at the specified level in the list.

[ API set: WordApi 1.3 ]

setLevelNumbering(level, listNumberingString, formatString)

Sets the numbering format at the specified level in the list.

[ API set: WordApi 1.3 ]

setLevelPicture(level, base64EncodedImage)

Sets the picture at the specified level in the list.

[ API set: WordApi BETA (PREVIEW ONLY) ]

setLevelStartingNumber(level, startingNumber)

Sets the starting number at the specified level in the list. Default value is 1.

[ API set: WordApi 1.3 ]

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Word.List object is an API object, the toJSON method returns a plain JavaScript object (typed as Word.Interfaces.ListData) that contains shallow copies of any loaded child properties from the original object.

track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you are using this object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created.

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect.

Property Details

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

id

Gets the list's id.

[ API set: WordApi 1.3 ]

readonly id: number;

Property Value

number

levelExistences

Checks whether each of the 9 levels exists in the list. A true value indicates the level exists, which means there is at least one list item at that level. Read-only.

[ API set: WordApi 1.3 ]

readonly levelExistences: boolean[];

Property Value

boolean[]

levelTypes

Gets all 9 level types in the list. Each type can be 'Bullet', 'Number', or 'Picture'. Read-only.

[ API set: WordApi 1.3 ]

readonly levelTypes: Word.ListLevelType[];

Property Value

paragraphs

Gets paragraphs in the list. Read-only.

[ API set: WordApi 1.3 ]

readonly paragraphs: Word.ParagraphCollection;

Property Value

Method Details

getLevelFont(level)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Gets the font of the bullet, number, or picture at the specified level in the list.

[ API set: WordApi BETA (PREVIEW ONLY) ]

getLevelFont(level: number): Word.Font;

Parameters

level
number

Required. The level in the list.

Returns

getLevelParagraphs(level)

Gets the paragraphs that occur at the specified level in the list.

[ API set: WordApi 1.3 ]

getLevelParagraphs(level: number): Word.ParagraphCollection;

Parameters

level
number

Required. The level in the list.

Returns

getLevelPicture(level)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Gets the base64 encoded string representation of the picture at the specified level in the list.

[ API set: WordApi BETA (PREVIEW ONLY) ]

getLevelPicture(level: number): OfficeExtension.ClientResult<string>;

Parameters

level
number

Required. The level in the list.

Returns

OfficeExtension.ClientResult<string>

getLevelString(level)

Gets the bullet, number, or picture at the specified level as a string.

[ API set: WordApi 1.3 ]

getLevelString(level: number): OfficeExtension.ClientResult<string>;

Parameters

level
number

Required. The level in the list.

Returns

OfficeExtension.ClientResult<string>

insertParagraph(paragraphText, insertLocation)

Inserts a paragraph at the specified location.

[ API set: WordApi 1.3 ]

insertParagraph(paragraphText: string, insertLocation: Word.InsertLocation): Word.Paragraph;

Parameters

paragraphText
string

Required. The paragraph text to be inserted.

insertLocation
Word.InsertLocation

Required. The value can be 'Start', 'End', 'Before', or 'After'.

Returns

insertParagraph(paragraphText, insertLocationString)

Inserts a paragraph at the specified location.

[ API set: WordApi 1.3 ]

insertParagraph(paragraphText: string, insertLocationString: "Before" | "After" | "Start" | "End" | "Replace"): Word.Paragraph;

Parameters

paragraphText
string

Required. The paragraph text to be inserted.

insertLocationString
"Before" | "After" | "Start" | "End" | "Replace"

Required. The value can be 'Start', 'End', 'Before', or 'After'.

Returns

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

load(option?: Word.Interfaces.ListLoadOptions): Word.List;

Parameters

Returns

Remarks

In addition to this signature, this method has the following signatures:

load(option?: string | string[]): Word.List - Where option is a comma-delimited string or an array of strings that specify the properties to load.

load(option?: { select?: string; expand?: string; }): Word.List - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.List - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Word.List;

Parameters

propertyNames
string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: { select?: string; expand?: string; }): Word.List;

Parameters

propertyNamesAndPaths
{ select?: string; expand?: string; }

Where propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

resetLevelFont(level, resetFontName)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Resets the font of the bullet, number, or picture at the specified level in the list.

[ API set: WordApi BETA (PREVIEW ONLY) ]

resetLevelFont(level: number, resetFontName?: boolean): void;

Parameters

level
number

Required. The level in the list.

resetFontName
boolean

Optional. Indicates whether to reset the font name. Default is false that indicates the font name is kept unchanged.

Returns

void

setLevelAlignment(level, alignment)

Sets the alignment of the bullet, number, or picture at the specified level in the list.

[ API set: WordApi 1.3 ]

setLevelAlignment(level: number, alignment: Word.Alignment): void;

Parameters

level
number

Required. The level in the list.

alignment
Word.Alignment

Required. The level alignment that can be 'Left', 'Centered', or 'Right'.

Returns

void

setLevelAlignment(level, alignmentString)

Sets the alignment of the bullet, number, or picture at the specified level in the list.

[ API set: WordApi 1.3 ]

setLevelAlignment(level: number, alignmentString: "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified"): void;

Parameters

level
number

Required. The level in the list.

alignmentString
"Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified"

Required. The level alignment that can be 'Left', 'Centered', or 'Right'.

Returns

void

setLevelBullet(level, listBullet, charCode, fontName)

Sets the bullet format at the specified level in the list. If the bullet is 'Custom', the charCode is required.

[ API set: WordApi 1.3 ]

setLevelBullet(level: number, listBullet: Word.ListBullet, charCode?: number, fontName?: string): void;

Parameters

level
number

Required. The level in the list.

listBullet
Word.ListBullet

Required. The bullet.

charCode
number

Optional. The bullet character's code value. Used only if the bullet is 'Custom'.

fontName
string

Optional. The bullet's font name. Used only if the bullet is 'Custom'.

Returns

void

setLevelBullet(level, listBulletString, charCode, fontName)

Sets the bullet format at the specified level in the list. If the bullet is 'Custom', the charCode is required.

[ API set: WordApi 1.3 ]

setLevelBullet(level: number, listBulletString: "Custom" | "Solid" | "Hollow" | "Square" | "Diamonds" | "Arrow" | "Checkmark", charCode?: number, fontName?: string): void;

Parameters

level
number

Required. The level in the list.

listBulletString
"Custom" | "Solid" | "Hollow" | "Square" | "Diamonds" | "Arrow" | "Checkmark"

Required. The bullet.

charCode
number

Optional. The bullet character's code value. Used only if the bullet is 'Custom'.

fontName
string

Optional. The bullet's font name. Used only if the bullet is 'Custom'.

Returns

void

setLevelIndents(level, textIndent, bulletNumberPictureIndent)

Sets the two indents of the specified level in the list.

[ API set: WordApi 1.3 ]

setLevelIndents(level: number, textIndent: number, bulletNumberPictureIndent: number): void;

Parameters

level
number

Required. The level in the list.

textIndent
number

Required. The text indent in points. It is the same as paragraph left indent.

bulletNumberPictureIndent
number

Required. The relative indent, in points, of the bullet, number, or picture. It is the same as paragraph first line indent.

Returns

void

setLevelNumbering(level, listNumbering, formatString)

Sets the numbering format at the specified level in the list.

[ API set: WordApi 1.3 ]

setLevelNumbering(level: number, listNumbering: Word.ListNumbering, formatString?: Array<string | number>): void;

Parameters

level
number

Required. The level in the list.

listNumbering
Word.ListNumbering

Required. The ordinal format.

formatString
Array<string | number>

Optional. The numbering string format defined as an array of strings and/or integers. Each integer is a level of number type that is higher than or equal to this level. For example, an array of ["(", level - 1, ".", level, ")"] can define the format of "(2.c)", where 2 is the parent's item number and c is this level's item number.

Returns

void

setLevelNumbering(level, listNumberingString, formatString)

Sets the numbering format at the specified level in the list.

[ API set: WordApi 1.3 ]

setLevelNumbering(level: number, listNumberingString: "None" | "Arabic" | "UpperRoman" | "LowerRoman" | "UpperLetter" | "LowerLetter", formatString?: Array<string | number>): void;

Parameters

level
number

Required. The level in the list.

listNumberingString
"None" | "Arabic" | "UpperRoman" | "LowerRoman" | "UpperLetter" | "LowerLetter"

Required. The ordinal format.

formatString
Array<string | number>

Optional. The numbering string format defined as an array of strings and/or integers. Each integer is a level of number type that is higher than or equal to this level. For example, an array of ["(", level - 1, ".", level, ")"] can define the format of "(2.c)", where 2 is the parent's item number and c is this level's item number.

Returns

void

setLevelPicture(level, base64EncodedImage)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Sets the picture at the specified level in the list.

[ API set: WordApi BETA (PREVIEW ONLY) ]

setLevelPicture(level: number, base64EncodedImage?: string): void;

Parameters

level
number

Required. The level in the list.

base64EncodedImage
string

Optional. The base64 encoded image to be set. If not given, the default picture is set.

Returns

void

setLevelStartingNumber(level, startingNumber)

Sets the starting number at the specified level in the list. Default value is 1.

[ API set: WordApi 1.3 ]

setLevelStartingNumber(level: number, startingNumber: number): void;

Parameters

level
number

Required. The level in the list.

startingNumber
number

Required. The number to start with.

Returns

void

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Word.List object is an API object, the toJSON method returns a plain JavaScript object (typed as Word.Interfaces.ListData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Word.Interfaces.ListData;

Returns

track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you are using this object across ".sync" calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you needed to have added the object to the tracked object collection when the object was first created.

track(): Word.List;

Returns

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You will need to call "context.sync()" before the memory release takes effect.

untrack(): Word.List;

Returns