Skip to main content

RemoveElement

Removes an element using the position specified.

Syntax

expression.RemoveElement(nPos);

expression - A variable that represents a ApiDocumentContent class.

Parameters

NameRequired/OptionalData typeDefaultDescription
nPosRequirednumberThe element number (position) in the document or inside other element.

Returns

boolean

Example

This example shows how to remove an element.

// How to remove an elements from the slide shape.

// Get a slide shape's content and remove an element from it using its index.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);

const docContent = shape.GetDocContent();
let paragraph = docContent.GetElement(0);
paragraph.AddText("This is the first paragraph.");
docContent.RemoveElement(0);
paragraph = Api.CreateParagraph();
paragraph.AddText("This is the second paragraph. The first paragraph was removed from the document content.");
docContent.Push(paragraph);
slide.AddObject(shape);