xwei_chen
xwei_chen

Reputation: 65

how to edit word comment in c# code (use dsoframer)

When I was in use the dsoframer operation word had a problem.

i can add a comment by code like this

   Microsoft.Office.Interop.Word.Comment cm = 
word.Comments.Add(word.Application.Selection.Range, "test");
int ctIndex = cm.Index;

but how to update the comment content? I can't find any function to do this!

word.Comments[ctIndex]..

Upvotes: 1

Views: 596

Answers (1)

Bassam Alugili
Bassam Alugili

Reputation: 17003

Read:

var comments = wordApp.ActiveDocument.Comments;
    foreach (Comment comment in comments)
    {
      var commentText = comment.Range.Text;
      var scopeTxt = comment.Scope.Text;
        Console.WriteLine(commentText);
    }

Do not forget to mark it as answer if this solve your problem ^^

Write:

foreach (Comment comment in comments)
      {
        comment.Range.Text = "Write a new text here";
      }

Upvotes: 1

Related Questions