Skip to main content

ReplaceByElement

Replaces the current content control with a new element.

Syntax

expression.ReplaceByElement(oElement);

expression - A variable that represents a ApiBlockLvlSdt class.

Parameters

NameRequired/OptionalData typeDefaultDescription
oElementRequiredDocumentElementThe element to replace the current content control with.

Returns

boolean

Example

This example replaces the content control with a paragraph.

let doc = Api.GetDocument();
let blockLvlSdt = Api.CreateBlockLvlSdt();
doc.AddElement(0, blockLvlSdt);
blockLvlSdt.SetPlaceholderText("Name");
let paragraph = Api.CreateParagraph();
paragraph.AddText("The content control was replaced with the current paragraph.");
blockLvlSdt.ReplaceByElement(paragraph);