Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.
Thu Feb 11, 2021 1:55 pm
Hi Spire Supporter,
I'm using VB.NET trying to search for words in the paragraph that have marked and comment on it. I can easily know which paragraph that has comment but unable to pinpoint the group of words that have been marked for comment. Could you have a look at the attached photo ? Do we have anyway in the code to know the phrase ".NET introduction" is marked for comment ?
Login to view the files attached to this post.
-
htchanit
-
- Posts: 3
- Joined: Wed Jun 03, 2020 2:26 pm
Fri Feb 12, 2021 9:09 am
Hello,
Thanks for your inquiry.
Please refer to the following example code.
- Code: Select all
Dim doc As Document = New Document()
doc.LoadFromFile("C:/test.docx")
Dim textRanges As List(Of TextRange) = New List(Of TextRange)()
For Each comment As Comment In doc.Comments
Dim paragraph As Paragraph = comment.OwnerParagraph
For i As Integer = 0 To paragraph.ChildObjects.Count - 1
If paragraph.ChildObjects(i).DocumentObjectType = DocumentObjectType.CommentMark Then
If (TryCast(paragraph.ChildObjects(i), CommentMark)).Type = CommentMarkType.CommentStart Then
While TypeOf paragraph.ChildObjects(i).NextSibling Is TextRange
textRanges.Add(TryCast(paragraph.ChildObjects(i).NextSibling, TextRange))
i += 1
End While
Exit For
End If
End If
Next
Next
If the above code doesn't meet your requirement, please tell me and share your example Word file, I will do a demo for you.
Sincerely
Amy
E-iceblue support team
-
amy.zhao
-
- Posts: 2767
- Joined: Wed Jun 27, 2012 8:50 am
Sat Feb 20, 2021 10:13 am
Hello,
Greetings from E-iceblue!
Has your issue been resolved?
I will appreciate it if you could give me some feedback at your convenience.
Sincerely
Amy
E-iceblue support team
-
amy.zhao
-
- Posts: 2767
- Joined: Wed Jun 27, 2012 8:50 am
Thu Feb 25, 2021 7:08 pm
Hi Amy,
Thanks for your help. I got it working
Great !
Regards,
Tom Huynh
-
htchanit
-
- Posts: 3
- Joined: Wed Jun 03, 2020 2:26 pm
Fri Feb 26, 2021 1:24 am
Hello,
Thanks for your feedback.
Glad to hear that your issue has been solved.
Feel free to contact us if you have any issues in the future.
Sincerely
Amy
E-iceblue support team
-
amy.zhao
-
- Posts: 2767
- Joined: Wed Jun 27, 2012 8:50 am