Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,I have to alert user about red lining comments before processing the word document. I am able to loop through comments in the word document but could not find a way if the lines are red (the document has both red lines and blue lines for the comments). I am using "Microsoft.Office.Interop.Word"

What I have tried:

Dim strComments As String = ""
       For Each c In wrdDoc.Comments
           strComments = strComments & c.Done & vbCrLf & c.Range.Text & vbCrLf
           'check if the comment lines are red and alert
       Next
       RichTextBox1.Text = strComments
Posted
Updated 26-Jul-23 17:56pm

 
Share this answer
 
v2
Comments
Harikavulli 27-Jul-23 6:41am    
Hi Thanks for responding. Could you please help me with some sample code. I have tried below code according to the link you provided

If c.Scope.Font.Fill.BackColor.RGB = RGB(255, 0, 0) Then
blRedLine = True
End If

but it is giving me white color RGB. i think it is not backcolor instead i think it is some display setting or highlight color of the comments scope.
Ralf Meier 27-Jul-23 7:48am    
I'm sorry ... not really ... because I don't have your Document and also not your code.
But a suggestion : try to follow the sample from StackOverFlow ... and also : what does this Porperty deliver to you ?
Ralf Meier 27-Jul-23 7:51am    
But Ahmed has written that the Color comes from the Author-Settings and not from the comment itself ...
You probably need to examine the Properties of each individual comment: Comment Interface (Microsoft.Office.Interop.Word) | Microsoft Learn[^].
 
Share this answer
 
Comments
Harikavulli 26-Jul-23 11:13am    
Thanks for responding. I have already checked the properties of Comment Interface, but could not find exact property for identifying the red lined comments and blue lined comments. Any sample code would be really very helpful. Thank you
Richard MacCutchan 26-Jul-23 11:59am    
Sometimes if there is no specific answer to your query you need to do your own research.
Your code show nothing relative to colors. And, Word has absolutely no way to know if a text represents code or something else. In word a colored text is nothing more, or less, than a black test. It is just a color. Word cannot make any difference between a thesis, a receipe or a programm unless you provide a programm to do it,

You should look to Range.Font and not range.text.

Range.Font Property (Microsoft.Office.Interop.Word) | Microsoft Learn[^]


Font Interface (Microsoft.Office.Interop.Word) | Microsoft Learn[^]


But you may (should) use Word macro recorder to help you. You will get a Visual Basic for Application code. With VBA you will get one or more procedures with correct word classes, methods and properties. And you can easily copy-paste text from VBA editor to VS editor.You will need to adapt (mostly combine) them with Interop.word Namespace. But with Word macro recorder you cannot use mouse inside the document. All operations in document must be do with Keyboard.

And, If you add interop.word dll as a reference in your VS Project, you will get Intellisense information.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900