How to place the cursor to the first position in a page

J

Jeremy

I would like to be able to put my cursor (create a range) at the beggining
(top most) cursor position in a page.

I would appreciate your help
 
W

Word Heretic

G'day Jeremy <[email protected]>,

Iterate the characters of the range, examining their
Range.Information(wdActiveEndPageNumber) until it changes.


Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Jeremy reckoned:
 
D

Doug Robbins

Use

Selection.Bookmarks("\page").Range.Select
Selection.Collapse wdCollapseStart

or

Dim myrange as Range
Set myrange = Selection.Bookmarks("\page").Range
myrange.end = myrange.start

That will cause the range object myrange to be the first position on the
page. It will NOT move the selection to that point, which you may not need
to do. If you do need to, you would need to add

myrange.Select

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
W

Word Heretic

G'day "Doug Robbins" <[email protected]>,

Out of interest Doug, have you had problems using this method? I have,
maybe I should bother to investigate this further one day :)

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Doug Robbins reckoned:
 
D

Doug Robbins

Hi Steve,

It has always worked for me, not that I use it every day though.

Regards from Paris,
Doug Robbins - Word MVP
 
S

Shauna Kelly

Hi Doug, Steve

I find that Bookmarks("\page") fails if a row in a table breaks across a
page.

If the cursor in a row that breaks, on the page that the row starts, then
Selection.Bookmarks("\page").Range will return the whole of that page plus
the entire table going forward to the end of the table. If the cursor is in
a row that breaks, on a middle page of the row (ie if the row spans 3 pages
or more), then Selection.Bookmarks("\page").Range returns the entire table.
If the cursor is in a row that breaks, but on the last page of the table,
then Selection.Bookmarks("\page").Range returns the whole of that page plus
the entire table, going back to the beginning of the table.

Cheers

Shauna

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
H

Howard Kaikow

I find the following to be a safe way to do things.
Also, helps wean fokes off the selection object,

dim rng as Word.Range
set rng = activedocument.content
with rng
.collapse direction:=wdCollapseStart
.select
end with
 

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