I am able to extract all the comments from document, but I also need the comment’s paragraph and section index it is attached to. I know comment can be attached to multiple paragraph, so maybe an index of comment Range Start index would work.
Here is what I am trying to do in vb .net, but I know it is wrong:
Dim p As Paragraph
Dim pindex As String
Dim s As Section
Dim sindex As String
Dim collectedComments As New ArrayList()
’ Collect all comments in the document
Dim comments As NodeCollection = doc.GetChildNodes(NodeType.Comment, True)
’ Look through all comments and gather information about them.
For Each comment As Comment In comments
p = comment.GetAncestor(NodeType.Paragraph)
pindex = doc.GetChildNodes(NodeType.Paragraph, True).IndexOf§.ToString()
s = p.GetAncestor(NodeType.Section)
sindex = doc.GetChildNodes(NodeType.Section, True).IndexOf(s).ToString()
collectedComments.Add(comment.Author & " " & comment.DateTime & " " & comment.ToString(SaveFormat.Text) & " " & pindex & " " & sindex)