GetLastRunWithText

function GetLastRunWithText(): ApiRun

Description

Returns the last Run with text in the current paragraph.

Returns

ApiRun

Try It

var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
for (let nRunIncrease = 0; nRunIncrease < 5; ++nRunIncrease) {
   var oRun = Api.CreateRun();
   oRun.AddText("This run # " + (nRunIncrease + 1) );
   oParagraph.Push(oRun);
   oParagraph.AddLineBreak();
}
var oLastRun = oParagraph.GetLastRunWithText();
oLastRun.AddText(" Last run.");

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).