Solved

Macro: Move to end of page in Word

Posted on 2000-05-16
2
1,420 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
message box in access 4 52
vb6 connector to SQL Server 2 41
Sorting multiple rows and columns, and count duplicates in Excel 2013 4 93
Passing a Text Box name to a Sub 6 102
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

685 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