Avatar of oaktrees
oaktrees

asked on 

Help This Macro Work In My Long Document

I've been using this macro

Sub ScrollDown()
On Error GoTo ErrorHandler
  ActiveDocument.ActiveWindow.PageScroll Down:=1
ErrorHandler:
End Sub

-----

Sub ScrollUp()
'
' ScrollUp Macro
'
On Error GoTo ErrorHandler
  ActiveDocument.ActiveWindow.PageScroll Up:=1
ErrorHandler:
End
End Sub

Open in new window


for a detailed flash card-like review in word.  How it works: it keeps each page in a fixed window area.  So that, you can slam forward and backward through each page and the pages remain seemingly frozen.  Neither scrolling up or down, just seeming to repopulate with each click.

This macro works great!  But, the challenge I have is that - in the 700 page document I have - often I get scrolling down between the cards.
 So that the lower half of one card is across the top.  The upper half across the bottom. 2020-03-01_23-47-36-109.png
The hope was to have the macro, upon clicking, always bring the upper edge or the next card to the top of the page.

In this long document I have, once the pages have been moved down a little or up a little by hand, using the macro doesn't refocus the pages to the top of the next page.  It moves ahead only one full page area value.  Leaving me at the next two divided cards.

So, if I'm really cooking through a list of cards and then need to go up or down just a little in a card, or edit, I can't start clicking ahead or backwards with the next full card in the screen.  I need to carefully bring the next full card into view, set in the center of the screen.

It DOES work in the demo file attached, but, in the long document I have, somehow it's won't focus to the top of each page if the pages get pulled beyond the edges of the screen.  They don't snap back to fill the screen.

Also, in my file, it will often focus to the top of the CONTENT area of the page, putting the header just before the edge of the screen.

Can't post the actual long document, as it's all my research! :D  Posting a sample of what the pages I have look like.  But - that's the conundrum.  In the sample...the macro above works! :|.....  Always snaps back.

Thanks,

OT
macro-so-page-down-and-page-up-alwa.docx
VBAMicrosoft Word

Avatar of undefined
Last Comment
Martin Liss

8/22/2022 - Mon