Word VBA >> Retrieve page number of a comment
by rgoubet » Mon, 26 Jul 2004 19:48:22 GMT
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
Word VBA >> Retrieve page number of a comment
by Dave Lett » Mon, 26 Jul 2004 20:46:27 GMT
Hi Raphael,
You can use something like the following:
MsgBox
ActiveDocument.Comments(1).Reference.Information(wdActiveEndAdjustedPageNumb
er)
HTH,
Dave
Word VBA >> Retrieve page number of a comment
by Jonathan West » Mon, 26 Jul 2004 20:48:52 GMT
Hi Raphael,
The page number can be obtained from the Information(wdActiveEndPageNumber)
property of the Range of the comment.
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Retrieve page number of a comment
by rgoubet » Tue, 27 Jul 2004 14:14:02 GMT
That's one I'd never heard of. Glad to learn it.
Thanks!
Raph
Retrieve page number of a comment
by rgoubet » Wed, 28 Jul 2004 15:18:28 GMT
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.
Retrieve page number of a comment
by Jonathan West » Wed, 28 Jul 2004 18:58:06 GMT
Information(wdActiveEndPageNumber)
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.
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Retrieve page number of a comment
by Dave Lett » Wed, 28 Jul 2004 21:06:12 GMT
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
window
Retrieve page number of a comment
by rgoubet » Thu, 29 Jul 2004 16:02:59 GMT
Hi Dave,
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
Retrieve page number of a comment
by Dave Lett » Thu, 29 Jul 2004 20:31:35 GMT
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
normal),
comment,
Similar Threads
1. Retrieve Last Page number
How to obtain last page number?
I upgraded from Crystal ActiveX Control (OCX) to Report Designer
Component (RDC) and Crystal Report Viewer.
Old OCX provided a function called PageCount, for example:
NumberofPages = CrystalReport1.PageCount
eturns 100 if the number of pages in the specified report is 100.
And now?
2. retrieve Total page number - VB Crystal Report
3. "Insert->Page Numbers" vs "Header and Footer->Insert Page Number"
I working on VBA to insert a document number into the footer. Some of my
users add page numbers from the Insert menu, others add them from the H&F
toolbar. Unfortunately, Word seems to treat them very differently.
When the Insert menu is used, Word seems to add a text box containing the
page number. In the footer.range.text, this text box seems to exist in front
of the rest of the contents of the footer, even if visually the text box is
after or below the other contents.
How do I access that text box through VBA?
Thanks.
4. Retrieving page number count from Word DOC - Excel
5. Retrieve current page number
Dear All!
I'm currently working on a project, that automatically creates large
tech-manuals as .doc - files.
To set up a table of contents I need to figure out the page number of a
range object.
In other words: I have a range object, which - for sure - only marks text in
one page and I want to know on which page this range object is.
Kind regards,
Daniel Lang
6. retrieve current page number with vba - Word VBA
7. How to retrieve active page number from code?
Hi All,
How can I retrieve active page number (the number that is displayed in the
status bar's left-most panel) from VBA code? I am using Word 2000.
Thank you in advance
Robert
8. Page numbering in footers, Outside margin, Page Number + Number of Pages