CreateRange

function CreateRange(oElement: any = null, nStart: any = null, nEnd: any = null): ApiRange | "null"

Description

Creates an element range. If you do not specify the start and end positions, the range will be taken from the entire element.

Parameters

oElementanydefault: null

The element from which the range will be taken.

nStartanydefault: null

Start range position.

nEndanydefault: null

End range position.

Returns

ApiRange | "null"

Try It

var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("ONLYOFFICE Document Builder");
var oRange = Api.CreateRange(oParagraph, 0, 9);
oRange.SetBold(true);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).