Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Get page number of range?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matthew Leingang - 31 Mar 2005 18:07 GMT
Hello,

I'm reviewing and making comments on a number of long documents.  The client
wants the comments in a separate document, though, so I thought I'd write a
macro to extract comments.

I want something like:

Page 2, Paragraph 3
This is a brilliant insight!

Page 4, Paragraph 5
Actually, this is false.

And so on...

So far I've got this:

--------
Public Sub CopyComments()

Dim i As Integer
Dim curDoc As Document
Dim newDoc As Document
Dim rng As Range
Dim cmt As Comment

Set curDoc = ActiveDocument
Set newDoc = Documents.Add
Set rng = newDoc.Range

For i = 1 To curDoc.Comments.Count
   Set cmt = curDoc.Comments(i)
   rng.InsertAfter ("PAGE: " & cmt.Scope.Information(wdActiveEndPageNumber)
& vbCr)
   rng.InsertAfter ("SCOPE:" & cmt.Scope & vbCr)
   rng.InsertAfter ("COMMENT: " & cmt.Range & vbCr & vbCr)
   
Next i
End Sub
--------

I saw the Information call used somewhere to get the page of the cursor
selection, so I thought it would adapt.  Instead,
cmt.Scope.Information(wdActiveEndPageNumber) returns -1.

This is my first experience with VBA.  Any clues?

TIA,
Matt

Signature

Matthew Leingang
Remove caps for correct email address

Helmut Weber - 31 Mar 2005 19:47 GMT
Hi Matthew,

your code works perfectly here and now.
Which doesn't help you much, of course, I'm sorry.

In some versions of Word higher than 97
Selection.Information(wdFirstCharacterLineNumber)
returns -1, unless views, e.g. normal view versus print view,
where not switched to and fro before.

Maybe there are similar effects with wdActiveEndPageNumber.

At least you know, it has nothing to do with your code.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Matthew Leingang - 31 Mar 2005 20:57 GMT
Dear Helmut,

Thanks for checking.  I probably should have mentioned that I'm using Word
2004 for Mac.  Maybe that's the problem.

I was able to work around by selecting each range, then getting the
selection's information:

   Set cmt = curDoc.Comments(i)
   cmt.scope.Select
   rng.InsertAfter ("Page " & Selection.Information(wdActiveEndPageNumber)
& ", ")
   rng.InsertAfter ("line " &
Selection.Information(wdFirstCharacterLineNumber) & ": ")

I know, originally I had wanted to give the paragraph number but this is
just as good.  

Yours,
Matthew Leingang <-- ein deutsche Name.  Meine Vorfahren kommen aus der
Pfalz

On 3/31/05 1:47 PM, in article 1jgo41hji9rd3oi7ivlj46otdin0dnv5uj@4ax.com,

> Hi Matthew,
>
[quoted text clipped - 16 lines]
> Word XP, Win 98
> http://word.mvps.org/

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.