Word.List class
Contains a collection of Word.Paragraph objects.
- 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. |
level |
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. |
level |
Gets all 9 level types in the list. Each type can be 'Bullet', 'Number', or 'Picture'. Read-only. |
paragraphs | Gets paragraphs in the list. Read-only. |
Methods
get |
Gets the font of the bullet, number, or picture at the specified level in the list. |
get |
Gets the paragraphs that occur at the specified level in the list. |
get |
Gets the base64 encoded string representation of the picture at the specified level in the list. |
get |
Gets the bullet, number, or picture at the specified level as a string. |
insert |
Inserts a paragraph at the specified location. |
insert |
Inserts a paragraph at the specified location. |
load(option) | Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. |
load(property |
Queues up a command to load the specified properties of the object. You must call |
load(property |
Queues up a command to load the specified properties of the object. You must call |
reset |
Resets the font of the bullet, number, or picture at the specified level in the list. |
set |
Sets the alignment of the bullet, number, or picture at the specified level in the list. |
set |
Sets the alignment of the bullet, number, or picture at the specified level in the list. |
set |
Sets the bullet format at the specified level in the list. If the bullet is 'Custom', the charCode is required. |
set |
Sets the bullet format at the specified level in the list. If the bullet is 'Custom', the charCode is required. |
set |
Sets the two indents of the specified level in the list. |
set |
Sets the numbering format at the specified level in the list. |
set |
Sets the numbering format at the specified level in the list. |
set |
Sets the picture at the specified level in the list. |
set |
Sets the starting number at the specified level in the list. Default value is 1. |
toJSON() | Overrides the JavaScript |
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
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.
readonly levelExistences: boolean[];
Property Value
levelTypes
Gets all 9 level types in the list. Each type can be 'Bullet', 'Number', or 'Picture'. Read-only.
readonly levelTypes: Word.ListLevelType[];
Property Value
paragraphs
Gets paragraphs in the list. Read-only.
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
Returns
getLevelParagraphs(level)
Gets the paragraphs that occur at the specified level in the list.
getLevelParagraphs(level: number): Word.ParagraphCollection;
Parameters
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
Returns
getLevelString(level)
Gets the bullet, number, or picture at the specified level as a string.
getLevelString(level: number): OfficeExtension.ClientResult<string>;
Parameters
Returns
insertParagraph(paragraphText, insertLocation)
Inserts a paragraph at the specified location.
insertParagraph(paragraphText: string, insertLocation: Word.InsertLocation): Word.Paragraph;
Parameters
Returns
insertParagraph(paragraphText, insertLocationString)
Inserts a paragraph at the specified location.
insertParagraph(paragraphText: string, insertLocationString: "Before" | "After" | "Start" | "End" | "Replace"): Word.Paragraph;
Parameters
- 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
- resetFontName
- boolean
Optional. Indicates whether to reset the font name. Default is false that indicates the font name is kept unchanged.
Returns
setLevelAlignment(level, alignment)
Sets the alignment of the bullet, number, or picture at the specified level in the list.
setLevelAlignment(level: number, alignment: Word.Alignment): void;
Parameters
Returns
setLevelAlignment(level, alignmentString)
Sets the alignment of the bullet, number, or picture at the specified level in the list.
setLevelAlignment(level: number, alignmentString: "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified"): void;
Parameters
- alignmentString
- "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified"
Required. The level alignment that can be 'Left', 'Centered', or 'Right'.
Returns
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.
setLevelBullet(level: number, listBullet: Word.ListBullet, charCode?: number, fontName?: string): void;
Parameters
Returns
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.
setLevelBullet(level: number, listBulletString: "Custom" | "Solid" | "Hollow" | "Square" | "Diamonds" | "Arrow" | "Checkmark", charCode?: number, fontName?: string): void;
Parameters
- listBulletString
- "Custom" | "Solid" | "Hollow" | "Square" | "Diamonds" | "Arrow" | "Checkmark"
Required. The bullet.
Returns
setLevelIndents(level, textIndent, bulletNumberPictureIndent)
Sets the two indents of the specified level in the list.
setLevelIndents(level: number, textIndent: number, bulletNumberPictureIndent: number): void;
Parameters
- bulletNumberPictureIndent
- number
Required. The relative indent, in points, of the bullet, number, or picture. It is the same as paragraph first line indent.
Returns
setLevelNumbering(level, listNumbering, formatString)
Sets the numbering format at the specified level in the list.
setLevelNumbering(level: number, listNumbering: Word.ListNumbering, formatString?: Array<string | number>): void;
Parameters
- 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
setLevelNumbering(level, listNumberingString, formatString)
Sets the numbering format at the specified level in the list.
setLevelNumbering(level: number, listNumberingString: "None" | "Arabic" | "UpperRoman" | "LowerRoman" | "UpperLetter" | "LowerLetter", formatString?: Array<string | number>): void;
Parameters
- 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
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
- base64EncodedImage
- string
Optional. The base64 encoded image to be set. If not given, the default picture is set.
Returns
setLevelStartingNumber(level, startingNumber)
Sets the starting number at the specified level in the list. Default value is 1.
setLevelStartingNumber(level: number, startingNumber: number): void;
Parameters
Returns
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
Feedback
Loading feedback...