Solved

Macro: Move to end of page in Word

Posted on 2000-05-16
2
964 Views
Last Modified: 2011-10-03
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
Comment
Question by:mat_w
2 Comments
 
LVL 17

Expert Comment

by:calacuccia
ID: 2815301
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
 
LVL 22

Accepted Solution

by:
ture earned 75 total points
ID: 2816123
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now