ReplaceCurrentWord

function ReplaceCurrentWord(
  sReplace: string = null,
  sPart: "undefined" | before | after = null,
): boolean

Description

Replace the current word or part of the current word with the specified text

Parameters

sReplacestringdefault: null

String to replace

sPart"undefined" | before | afterdefault: null

Specifies the desired part of the current word

Returns

boolean

Try It

let oDocument = Api.GetDocument();
let oPara1 = oDocument.GetElement(0);
oPara1.AddText("The quick brown ");
let oRun = oPara1.AddText("cat");
oPara1.AddText(" jumps over the lazy dog");
oRun.MoveCursorToPos(1);

oDocument.ReplaceCurrentWord("fox");


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