Comments.vb
  1. ''
  2. '' This code is part of Document Solutions for Word demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.Collections.Generic
  6. Imports System.Drawing
  7. Imports System.Linq
  8. Imports GrapeCity.Documents.Word
  9.  
  10. '' This sample demonstrates how to add comments to parts of document.
  11. Public Class Comments
  12. Public Function CreateDocx() As GcWordDocument
  13. Dim user1 = "Jaime Smith" '' user name For comments' author
  14. Dim user2 = "Jane Donahue" '' user name For comments' author
  15.  
  16. Dim doc = New GcWordDocument()
  17.  
  18. Dim pars = doc.Body.Paragraphs
  19.  
  20. Dim p1 = pars.Add("Paragraph 1: This is a paragraph of text with a comment added to the whole paragraph. ")
  21. Dim c1 = p1.GetRange().Comments.Add("Comment added to paragraph 1.", user1, Util.TimeNow(), "J.S.")
  22. Dim c2 = c1.Reply("Reply to comment 1.", user2)
  23. Dim c3 = c2.Reply("Reply to comment 2, closing the thread.", user1)
  24. c3.Done = True
  25.  
  26. Dim p2 = pars.Add("Paragraph 2: This is another paragraph of text, with a comment added to 3rd run. ")
  27. p2.GetRange().Runs.Add("This is run 2 of paragraph 2. ")
  28. Dim r = p2.GetRange().Runs.Add("This is run 3 of paragraph 2 with a comment. ")
  29. r.GetRange().Comments.Insert("Comment on run 3 of paragraph 2", user2, RangeLocation.Whole)
  30. p2.GetRange().Runs.Add("This is run 4 of paragraph 2. ")
  31. p2.GetRange().Runs.Add("This is run 5 of paragraph 2. ")
  32. p2.GetRange().Runs.Add("This is run 6 of paragraph 2. ")
  33.  
  34. '' Done
  35. Return doc
  36. End Function
  37. End Class
  38.