troubleshooting Question

Help This Macro Work In My Long Document

Avatar of oaktrees
oaktrees asked on
Microsoft WordVBA
26 Comments1 Solution96 ViewsLast Modified:
I've been using this macro

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


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

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.


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 26 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 26 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros