Comments on slides are author reviews and feedbacks about specified contents. Spire.Presentation for .NET enables developers to insert comments in PowerPoint slides with several lines of core code. Developers can also edit and remove the existing comments and replace with new comments for showing different reviews. This section will show how to edit and remove comments from presentation slides in C#.
Firstly check this PowerPoint document with three comments without removing and replacing.
Here comes to the steps of how to edit and remove the comments on presentation slides in C#.
Step 1: Create a new instance of presentation class and load a sample file with comments.
Presentation presentation = new Presentation(); presentation.LoadFromFile(@"..\..\sample.pptx");
Step 2: Replace the content in the first comment.
presentation.Slides[0].Comments[0].Text = "Revised comment";
Step 3: Remove the second comment
presentation.Slides[0].DeleteComment(presentation.Slides[0].Comments[1]);
Step 4: Save the document
presentation.SaveToFile(@"..\..\comment_2.pptx", FileFormat.Pptx2010);
Effective screenshot after edit and remove the comments on presentation slides:
Full codes:
namespace Comment { class Program { static void Main(string[] args) { Presentation presentation = new Presentation(); presentation.LoadFromFile(@"..\..\sample.pptx"); //Edit the first comment presentation.Slides[0].Comments[0].Text = "Revised comment"; //Remove the second comment presentation.Slides[0].DeleteComment(presentation.Slides[0].Comments[1]); //Save the document presentation.SaveToFile(@"..\..\comment_2.pptx", FileFormat.Pptx2010); } } }