Solved

Macro: Move to end of page in Word

Posted on 2000-05-16
2
1,634 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

688 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