Get Started
Documentation

ExpandTo

ExpandTo(oRange) → { ApiRange | null }

Returns a new range that goes beyond that range in any direction and spans a different range. The current range has not changed. Throws an error if the two ranges do not have a union.

Parameters:

Name Type Description
oRange ApiRange

Returns:

Type
ApiRange | null

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("Lorem ipsum dolor sit amet,");
oParagraph.AddText(" consectetuer adipiscing elit,");
oParagraph.AddText(" sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.");
oRangeFirst = oDocument.GetRange(0, 22);
oRangeSecond = oDocument.GetRange(49, 123);
oRange = oRangeFirst.ExpandTo(oRangeSecond);
oRange.SetItalic(true);
builder.SaveFile("docx", "ExpandTo.docx");
builder.CloseFile();

Resulting document