Results 1 to 15 of 15
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Posts
    989
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Going to beginning of page (Word 2003)

    What instruction can I use to go to the top of the current page? Thanks, Andy.

  2. #2
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Going to beginning of page (Word 2003)

    <P ID="edit" class=small>(Edited by Rudi on 03-May-05 12:26. Sorry, I tested it more and it dd not move the selection correctly!)</P>Try this:
    Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=0, Name:=""
    Regards,
    Rudi

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Going to beginning of page (Word 2003)

    Not very elegant, but should work:

    ActiveDocument.Bookmarks("page").Select
    Selection.Collapse

  4. #4
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Going to beginning of page (Word 2003)

    Jeez, thx Hans. Your reply opens a world of new capabilities for me. Only after seeing your bookmarks reference, and wondering where in the world you got a bookmark reference of "/page", did I turn to Word VBA help and discovered that there are quite a few reserved bookmarks that you can use in VBA to navigate with!!!
    This is really gonna be a help in future Word coding for me!
    Thanx a stack!
    Regards,
    Rudi

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Going to beginning of page (Word 2003)

    Rudi, your code in my WordXp jumped to the next page.

    This code, cunningly disguised as my own work (!) seems to stay on the same page:<pre>Public Function lngTopOfPage(rng As Range)
    rng.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=rng.Information(wdActiveEndPageNumber), Name:=""
    lngTopOfPage = Selection.Information(wdActiveEndPageNumber)
    'Sub TESTlngTopOfPage()
    ' MsgBox lngTopOfPage(Selection.Range)
    'End Sub
    End Function
    </pre>


  6. #6
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Going to beginning of page (Word 2003)

    I modified it a bit and it works with these changes:
    <pre>Public Function lngTopOfPage(rng As Range)
    rng.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, _
    Count:=rng.Information(wdActiveEndPageNumber), _
    Name:=""
    lngTopOfPage = Selection.Information(wdActiveEndPageNumber)
    End Function

    Sub TESTlngTopOfPage()
    Dim PgNo As Integer
    PgNo = lngTopOfPage(Selection.Range)
    Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=PgNo
    End Sub</pre>


    Thanx for the code. Now Andrew has a choice to use!! <img src=/S/yep.gif border=0 alt=yep width=15 height=15>

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Chris
    Regards,
    Rudi

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Going to beginning of page (Word 2003)

    Thanks, Rudi, it took me a while to see what was wrong. We want the selection point to actually go to the top of the page, right, not just think about it ....... hah hah. Got me!

  8. #8
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Going to beginning of page (Word 2003)

    Here's a simpler (albeit goofy) approach that also works:
    <pre> Set rngX = rngX.GoTo(What:=wdGoToPage, Name:="Andy")
    </pre>

    EDITED TO ADD: I should have noted that the Selection version of the same approach looks like this:
    <pre> Selection.GoTo What:=wdGoToPage, Name:="Andy"</pre>


  9. #9
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Going to beginning of page (Word 2003)

    Andrew will have to take his pick. Somehow I believe Hans's simple solution will get the go!

    I think its great to post a question and find 2 or 3 valid answers come back. Thats the great thing of this site! <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Regards,
    Rudi

  10. #10
    Star Lounger
    Join Date
    Jan 2001
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Going to beginning of page (Word 2003)

    Slightly more elegant:

    Selection.End = ActiveDocument.Bookmarks("page").Start
    ActiveWindow.ScrollIntoView Selection.Range, True

  11. #11
    Star Lounger
    Join Date
    Jan 2001
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Going to beginning of page (Word 2003)

    Here are a few predefined bookmarks that you don't find in any documentation anywhere:

    Row (current table row)
    Word (word under the insertion point)

    Unfortunately, there's not Sentence bookmark...

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Going to beginning of page (Word 2003)

    Thanks, that's better if you actually want to see the top of the page.

  13. #13
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Going to beginning of page (Word 2003)

    Thanx Don. These bookmarks can prove VERY useful!
    Cheers
    Regards,
    Rudi

  14. #14
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Going to beginning of page (Word 2003)

    You can find more under 'Predefined Bookmarks' in Word's vba help too.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  15. #15
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Going to beginning of page (Word 2003)

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Macropod.
    Regards,
    Rudi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •