Retrieve page number of a comment

R

Raphael Goubet

Hi,

Does anybody know a way to retrieve the number of the page at which a
comment is located? PageNumber is not a property of the Comment
object, so I can't get it directly, and I can't find a PageNumber
property that would apply to a Range object either.

Thanks in advance.

Raphael
 
D

Dave Lett

Hi Raphael,

You can use something like the following:

MsgBox
ActiveDocument.Comments(1).Reference.Information(wdActiveEndAdjustedPageNumb
er)

HTH,
Dave
 
J

Jonathan West

Raphael Goubet said:
Hi,

Does anybody know a way to retrieve the number of the page at which a
comment is located? PageNumber is not a property of the Comment
object, so I can't get it directly, and I can't find a PageNumber
property that would apply to a Range object either.

Thanks in advance.


Hi Raphael,

The page number can be obtained from the Information(wdActiveEndPageNumber)
property of the Range of the comment.
 
R

Raphael Goubet

Jonathan West said:
The page number can be obtained from the Information(wdActiveEndPageNumber)
property of the Range of the comment.

Strangely, in my very long document,
Information(wdActiveEndPageNumber) does not return the same value when
referring to the Range object or to the Reference object (following
Dave's suggestion). Actually, the value from Range is -1!

Any idea as to why?

Raph.
 
J

Jonathan West

Raphael Goubet said:
"Jonathan West" <[email protected]> wrote in message

Strangely, in my very long document,
Information(wdActiveEndPageNumber) does not return the same value when
referring to the Range object or to the Reference object (following
Dave's suggestion). Actually, the value from Range is -1!

Any idea as to why?


Yes, the property returns -1 if the object is not visible in the editing
window. To fox this, use the ScrollIntoView method to get the editing window
to the right place.
 
D

Dave Lett

Hi Jonathan,

It seems like using the .Reference or .Scope property is the better
alternative:
1) It uses one line of code instead of three (select the comment, scroll to
the selection, then get its page number)[I couldn't get the routine to
return the correct number without selecting it, which is probably more a
testimony of my skills than your method].
2) It doens't requires the screen to move. Being self taught, one of the
things I've read is that if you can avoid moving the screen for the user
then use should (which is one of the major arguments for using the Range
object, but maybe an argument against using it in this case??)
3) .Reference refers to the the user's initials (when viewing from normal),
..Scope refers to the text that you highlighted when inserting the comment,
and .Range refers to the text of the comment itself. Therefore,
Range.Information(wdActiveEndAdjustedPageNumber) should always return -1,
shouldn't it? Here's my thought process: The text of comments aren't printed
inline; they're printed after the document like endnotes and, therefore,
don't have page numbers.

I'm pretty sure that this is right, but (since I'm self taught) I also
anticipate that there's something I have missed.

Dave
 
R

Raphael Goubet

Hi Dave,
3) .Reference refers to the the user's initials (when viewing from normal),
.Scope refers to the text that you highlighted when inserting the comment,
and .Range refers to the text of the comment itself.

That's indeed something I never got: the definition of the Reference
property is:
Returns a Range object that represents a footnote, endnote, or comment
reference mark.

But what's a reference mark exactly? What's the difference between
myComment.Range and myComment.Reference, where myComment is a Comment
object, if Reference returns a Range object?

Actually, in the case of Comments, I noticed that
Reference.Information(wdActiveEndPageNumber) and
Scope.Information(wdActiveEndPageNumber) do not return the same value
in one of my very long documents (over 350 pages). Only the latter is
the page where the comment is to be found. I have no clue what the
former refers to?

Thanks anyway for your help. I'm learning a lot from this discussion.

Raphael
 
D

Dave Lett

Hi Raphael,

The .Reference property is the little insertion that Word creates with your
username initials. .Scope is the range that you highlighted before you
inserted the comment (it's probably highlighted). .Comments(anynumber).Range
is the text of the comment itself.

To get the clearest understanding, you could run each of the following (run
one at a time):
ActiveDocument.Comments(1).Range.Select
ActiveDocument.Comments(1).Scope.Select
ActiveDocument.Comments(1).Reference.Select

HTH,
Dave
 

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