Add comments to bookmarks

Hi,

i have to add 2 comments to each bookmark existing in a document.

Here is my code:

Document doc = null;
using (MemoryStream mem = new MemoryStream(content))
{
    doc = new Document(mem);
}

DocumentBuilder builder = new DocumentBuilder(doc);

foreach (Bookmark b in doc.Range.Bookmarks)
{

    builder.MoveToBookmark(b.Name, true, true);
    // Create commentStart
    Comment commentStart = new Comment(doc);
    // commentStart.Author = "$DM$";
    // Add commentStart to the current paragraph
    builder.CurrentParagraph.AppendChild(commentStart);

    // Add text into the commentStart
    commentStart.Paragraphs.Add(new Paragraph(doc));
    commentStart.FirstParagraph.Runs.Add(new Run(doc, "Some Text"));

    builder.MoveToBookmark(b.Name, false, false);

    Comment commentEnd = new Comment(doc);
    builder.CurrentParagraph.AppendChild(commentEnd);

    commentEnd.Paragraphs.Add(new Paragraph(doc));
    commentEnd.FirstParagraph.Runs.Add(new Run(doc, "Some Text"));

}

But when i open the chapter no comments are shown.
What have i done wrong ?

Greeting

Guido

Hi Guido,

Thanks for your inquiry.

I think the following code can be of use to you: https://forum.aspose.com/t/problem-adding-comments-to-a-word-document/77321

If you have any further queries, please feel free to ask.

Thanks,