How to determine heading number of a paragraph that has comment

D

Deepabh Telang

Hi all ,
i my trying output a word document from a word document that has
comments by the reviewers. i need to make a table of author ,
heading(where the comment is) and the comment by reviewer.
i m able to get the author and comment but not able to get the
location of the comment on the document. How can i get it ??

Thanks
Deepabh
 
A

Andrew Savikas

You could try the Reference property of the comment:

Sub CommentInfo()
Dim cmt as Comment
For Each cmt in ActiveDocument.Comments
MsgBox cmt.Author & " said: " & _
cmt.Reference.Paragraphs(1).Range.Text
Next cmt
End Sub

You'd need to make some modifications if the comment
reference spanned more than one paragraph.

HTH,
Andrew Savikas
 
D

Deepabh Telang

Hi ,
Thanks for the help ..ur suggestion worked.Now i am facing following
problem .My word document is something like this
1. ABC
Here the paragraph starts............Few lines and then paragraph
ends.
1.1 DEF
Here the lines for the second paragraph.....Few lines and paragraph
ends.

My problem is when the reviewer comment is in "ABC", the
cmt.Reference.Paragraph(1).Range.ListFormat.ListString gives me the
outline "1" as required.
But when reviewer comment is somewhere between the paragraph the
cmt.Referen.... gives me empty string. How can i get "1.1"??

Thanks im Adv

Deepabh Telang
 
A

Andrew Savikas

Hello,

The ListString property is empty in between numbered
paragraphs because those paragraphs don't have numbers.

A workaround is to see if that ListString property is
empty, and if it is, start moving backward (up) in the
doucment by paragraph until you get to a paragraph that
does have a number (see below).

HTH,
Andrew Savikas

Sub CommentInfo()
Dim cmt As Comment
Dim liststr As String
Dim rng As Range
For Each cmt In ActiveDocument.Comments
Set rng = cmt.Reference.Paragraphs(1).Range
liststr = rng.ListFormat.ListString
Do While (liststr = "")
rng.Move wdParagraph, -1
liststr = rng.ListFormat.ListString
Loop

MsgBox "The most recent number is: " & liststr

' Clean up
liststr = ""
Set rng = Nothing
Next cmt
End Sub
 
M

Mark Tangard

What exactly do you mean by "when reviewer comment is somewhere
between the paragraph"? Between the paragraph and what?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top