Comments.vb
''
'' This code is part of GrapeCity Documents for Word samples.
'' Copyright (c) GrapeCity, Inc. All rights reserved.
''
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Linq
Imports GrapeCity.Documents.Word

'' This sample demonstrates how to add comments to parts of document.
Public Class Comments
    Public Function CreateDocx() As GcWordDocument
        Dim user1 = "Jaime Smith" '' user name For comments' author
        Dim user2 = "Jane Donahue" '' user name For comments' author

        Dim doc = New GcWordDocument()

        Dim pars = doc.Body.Sections.First.GetRange().Paragraphs

        Dim p1 = pars.Add("Paragraph 1: This is a paragraph of text with a comment added to the whole paragraph. ")
        Dim c1 = p1.GetRange().Comments.Add("Comment added to paragraph 1.", user1, DateTime.Now, "J.S.")
        Dim c2 = c1.Reply("Reply to comment 1.", user2)
        Dim c3 = c2.Reply("Reply to comment 2, closing the thread.", user1)
        c3.Done = True

        Dim p2 = pars.Add("Paragraph 2: This is another paragraph of text, with a comment added to 3rd run. ")
        p2.GetRange().Runs.Add("This is run 2 of paragraph 2. ")
        Dim r = p2.GetRange().Runs.Add("This is run 3 of paragraph 2 with a comment. ")
        r.GetRange().Comments.Insert("Comment on run 3 of paragraph 2", user2, RangeLocation.Whole)
        p2.GetRange().Runs.Add("This is run 4 of paragraph 2. ")
        p2.GetRange().Runs.Add("This is run 5 of paragraph 2. ")
        p2.GetRange().Runs.Add("This is run 6 of paragraph 2. ")

        '' Done
        Return doc
    End Function
End Class