# Delete all the comments by an author

> 

Source: https://docs.aspose.com/slides/net/delete-all-the-comments-by-an-author/
Updated: 2026-08-05


## **OpenXML SDK**
``` csharp

 string FilePath = @"..\..\..\..\Sample Files\";

string FileName = FilePath + "Delete all the comments by an author.pptx";

string author = "Zeeshan Shafqat";

DeleteCommentsByAuthorInPresentation(FileName, author);

// Remove all the comments in the slides by a certain author.

public static void DeleteCommentsByAuthorInPresentation(string fileName, string author)

{

if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(author))

    throw new ArgumentNullException("File name or author name is NULL!");

using (PresentationDocument doc = PresentationDocument.Open(fileName, true))

{

    // Get the specifed comment author.

    IEnumerable<CommentAuthor> commentAuthors =

        doc.PresentationPart.CommentAuthorsPart.CommentAuthorList.Elements<CommentAuthor>()

        .Where(e => e.Name.Value.Equals(author));

    // Iterate through all the matching authors.

    foreach (CommentAuthor commentAuthor in commentAuthors)

    {

        UInt32Value authorId = commentAuthor.Id;

        // Iterate through all the slides and get the slide parts.

        foreach (SlidePart slide in doc.PresentationPart.SlideParts)

        {

            SlideCommentsPart slideCommentsPart = slide.SlideCommentsPart;

            // Get the list of comments.

            if (slideCommentsPart != null && slide.SlideCommentsPart.CommentList != null)

            {

                IEnumerable<Comment> commentList =

                    slideCommentsPart.CommentList.Elements<Comment>().Where(e => e.AuthorId == authorId.Value);

                List<Comment> comments = new List<Comment>();

                comments = commentList.ToList<Comment>();

                foreach (Comment comm in comments)

                {

                    // Delete all the comments by the specified author.

                    slideCommentsPart.CommentList.RemoveChild<Comment>(comm);

                }

                // If the commentPart has no existing comment.

                if (slideCommentsPart.CommentList.ChildElements.Count == 0)

                    // Delete this part.

                    slide.DeletePart(slideCommentsPart);

            }

        }

        // Delete the comment author from the comment authors part.

        doc.PresentationPart.CommentAuthorsPart.CommentAuthorList.RemoveChild<CommentAuthor>(commentAuthor);

    }

}

}

``` 
## **Aspose.Slides**
``` csharp
using Aspose.Slides;
using Aspose.Slides.Export;

string filePath = @"..\..\..\..\Sample Files\";
string fileName = filePath + "Delete all the comments by an author.pptx";
string author = "MZ";

// Instantiate a Presentation object that represents a PPTX file
using (Presentation pres = new Presentation(fileName))
{
    // Remove all the comments in the slides by a certain author.
    ICommentAuthor[] authors = pres.CommentAuthors.FindByName(author);

    foreach (ICommentAuthor commentAuthor in authors)
    {
        for (int i = commentAuthor.Comments.Count - 1; i >= 0; i--)
        {
            commentAuthor.Comments.RemoveAt(i);
        }
    }

    pres.Save(fileName, SaveFormat.Pptx);
}
``` 
## **Download Sample Code**
- [GitHub](https://github.com/aspose-slides/Aspose.Slides-for-.NET/releases/tag/AsposeSlidesVsOpenXML1.1)
- [Sourceforge](https://sourceforge.net/projects/asposeopenxml/files/Aspose.Slides%20Vs%20OpenXML/Delete%20all%20the%20comments%20by%20an%20author%20%28Aspose.Slides%29.zip/download)
- [Bitbucket](https://bitbucket.org/asposemarketplace/aspose-for-openxml/src/master/Aspose.Slides%20Vs%20OpenXML/Delete%20all%20the%20comments%20by%20an%20author/)

