Get Started
Documentation

GetElement

GetElement(nPos) → { ParagraphContent }

Get the element of the current inline text content control using the position specified.

Parameters:

Name Type Description
nPos number

The position where the element which content we want to get must be located.

Returns:

Type
ParagraphContent

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oRun;
oParagraph = oDocument.GetElement(0);
oInlineLvlSdt = Api.CreateInlineLvlSdt();
oParagraph.AddInlineLvlSdt(oInlineLvlSdt);
for (var nPos = 0; nPos < 10; ++nPos) {
var curRun = oRun + nPos;
curRun = Api.CreateRun();
curRun.AddText("This is text run " + (nPos + 1) + ". ");
oInlineLvlSdt.AddElement(curRun);
}
var changeRun = oInlineLvlSdt.GetElement(4);
changeRun.SetBold(true);
oParagraph.AddLineBreak();
oParagraph.AddLineBreak();
oParagraph.AddLineBreak();
oParagraph.AddText("We added 10 text runs to the above inline text content control. Then we changed the fifth run, so it is different from the others.");
builder.SaveFile("docx", "GetElement.docx");
builder.CloseFile();

Resulting document