What Page is It?

K

Ken Hutson

Hi Group,

I have a question. Through code, I know how many pages and paragraphs are
in my document. If I know a particular page, how do I find the last word on
that page?

Thanks,
Ken Hutson
San Antonio
 
H

Helmut Weber

Hi Ken,
like this(last word from page 2), but only in principle:
With Selection
.ExtendMode = False
.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Name:="2"
.ExtendMode = True
.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="3"
MsgBox .Words.Last
End With
As I don't think, that this is possible without moving the selection,
you may add some code for restoring the selection. And some extra
code for getting the last word from the last page. And after all,
Word's definition of "word" is different from a word in natural
language. Let us know, if you need more detailed advice.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 
H

Helmut Weber

Hi,
still shorter to select the first page of the selection:
ActiveDocument.Bookmarks("\page").Select
 
P

Pete Bennett

You don't even need to select any text, just use the range of the bookmark.

?activedocument.Bookmarks("\page").range.paragraphs.last.Previous.Range.text

Strangely though,
activedocument.Bookmarks("\page").range.paragraphs.last.Previous.Range.words.Last.Text
doesn't return the last word, only individual characters (at least in Word
2003). Odd that...

Pete.
 

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