Skip to main content
A newer version of this page is available. .

InsertTextCommand.execute(text) Method

Executes the InsertTextCommand command by applying the specified settings.

May result in taking no action if the command’s state does not allow command execution. Use the object’s getState method to check the command state.

Declaration

execute(
    text: string,
    interval?: Interval | number,
    subDocumentId?: number
): boolean

Parameters

Name Type Description
text string

A string value specifying a text to insert.

interval Interval | number
subDocumentId number

An integer value specifying the sub-document.

Returns

Type Description
boolean

A Boolean value identifying whether method execution was successful or failed.

Remarks

The execute method checks the command state (obtained using the getState method) before executing, and decides whether the action can be performed.

Note that this method’s overload does not change the selection

Usage example:


var subDocumentId = richEdit.document.activeSubDocument.id;
var insertPosition = 75;
richEdit.commands.insertText.execute("an example text", insertPosition, subDocumentId);

If you need to access a header/footer sub-document, you can use the Section‘s Section.headers and Section.footers members. A document’s sections are available via the RichEditDocument.sectionsInfo property.

See Also