跳到主要内容

GetAllComments

Returns all comments from the current presentation.

Syntax

expression.GetAllComments();

expression - A variable that represents a ApiPresentation class.

Parameters

This method doesn't have any parameters.

Returns

ApiComment[]

Example

This example returns all comments from the current presentation.

// How to return an array of all comments from the ApiPresentation object and add a text of the first comment to the created shape.

// Get the ApiComment objects from the current presentation.

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

const posX = 15 * 36000;
const posY = 35 * 36000;

const fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("rect", 300 * 36000, 130 * 36000, fill, stroke);
shape.SetPosition(posX, posY);
slide.AddObject(shape);

slide.AddComment(posX, posY, "Comment 1", "John Smith");
const comments = presentation.GetAllComments();

const docContent = shape.GetDocContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText("Comment text: " + comments[0].GetText());