Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2285
  • Last Modified:

Macro: Move to end of page in Word

What is the Word 97 marco code to move to the end of the current page?  I need something that will work no matter if I'm on the last page of the document or in the middle somewhere.  Everything that I have tried doesn't work for both instances.

I know this is probably simple, but I can't find an example or info anywhere!

Thanks!
0
mat_w
Asked:
mat_w
1 Solution
 
calacucciaCommented:
Hi Mat_W,

Not as simple as that:

In Word VBA, you can use this little sub (or just the code inside):

Sub GoToEndOfPage()
Selection.GoTo What:=wdGoToBookmark, Name:="\Page"
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1
End Sub


IF calling Word from externally, with the Word Application called wdApp, use

wdApp.Selection.GoTo What:=wdGoToBookmark, Name:="\Page"
wdApp.Selection.MoveRight Unit:=wdCharacter, Count:=1
wdApp.Selection.MoveLeft Unit:=wdCharacter, Count:=1


Hope this helps
Calacuccia
0
 
tureCommented:
mat_w,

This one moves the cursor to the end of the current page, also when the cursor is on the last page.

Sub GoToEndOfPage()
  If Selection.Information(wdActiveEndPageNumber) < Selection.Information(wdNumberOfPagesInDocument) Then
    Selection.GoToNext wdGoToPage
    Selection.MoveLeft
  Else
    Selection.EndKey Unit:=wdStory
  End If
End Sub

Ture Magnusson
Karlstad, Sweden
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now