跳到主要内容

ReplaceByElement

用新元素替换当前段落。

语法

expression.ReplaceByElement(oElement);

expression - 表示 ApiParagraph 类的变量。

参数

名称必需/可选数据类型默认值描述
oElement必需DocumentElement用于替换当前段落的元素。

返回值

boolean

示例

此示例用块级内容控件替换段落。

// How to replace paragraph with another element.

// Add a block level content control instead of the paragraph.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is just a sample paragraph.");
let blockLvlSdt = Api.CreateBlockLvlSdt();
blockLvlSdt.GetContent().GetElement(0).AddText("The paragraph was replaced with the current content control.");
paragraph.ReplaceByElement(blockLvlSdt);