#1
|
|||
|
|||
Scroll through pages on loop
Hi everyone. I am pretty new to Macros and VB but I am working on a project as follows:
I need to create a macro that scrolls down through all pages in a word doc then scrolls back up. I will need to be able to control the scroll speed, either with a timer or setting. I am displaying our Court's docket on a display (as a word doc) and need to have it slowly scroll up and down throughout the day. The docket page length varies daily; anywhere from 1 page to 6 pages. We highlight text and markup the document throughout the day and autosave the document every 5 minutes. Any help would be appreciated. Right now. I am simply using a timer macro to scroll down one line every 3 seconds. This means that someone needs to manually scroll the document back up to the top. I'm hoping to improve on this. |
#2
|
||||
|
||||
You could use something like:
Code:
Sub Demo() Dim Rng As Range, Start Const Pause As Long = 2 ' Set duration. Recycle: With ActiveDocument.Range Set Rng = .Characters.First Do Start = Timer Do While Timer < Start + Pause DoEvents ' Yield to other processes. Loop Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\Line") If Rng.End = .End - 1 Then GoTo Recycle With Rng .Collapse wdCollapseEnd .Select End With Loop End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Paul,
Here your code moved down the page lines but only displays the cursor at the start of the line. I'm not sure if the line should be selected or not. If so, this alteration of your code does that. Code:
Sub Demo() Dim Rng As Range, Start Const Pause As Long = 2# Recycle: With ActiveDocument.Range Set Rng = .Characters.First Do While Rng.End < .End - 1 Start = Timer Do While Timer < Start + Pause DoEvents ' Yield to other processes. Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\Line") Rng.Select Loop If Rng.End = .End - 1 Then GoTo Recycle Rng.Collapse wdCollapseEnd Loop End With End Sub |
#4
|
||||
|
||||
The idea in the code I posted was not to select the line, but only to scroll.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Paul,
Ok. Like I said, I just wasn't sure what the OP might actually want/need so I posted the variation to save them having to ask for a mod. |
#6
|
|||
|
|||
Thank you!
Thanks you so much! This will work perfectly for what I need. I have spent alot of time messing around with this and I really appreciate such useful input.
|
Tags |
scrolling |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Advanced page numbering: section pages in header, document pages in footer | Albus | Word | 12 | 12-12-2014 01:36 PM |
Page does not actively scroll with click, hold and drag on scroll-bar | jbax | Word | 1 | 05-09-2013 07:16 PM |
parallel text on even pages and on odd pages | markpete | Word | 3 | 11-16-2012 03:10 AM |
Forcing Chapter Start Pages on Odd Pages | SQLUSA | Word | 3 | 08-16-2012 02:40 PM |
Scroll Box | john_prince | Word | 0 | 02-01-2011 03:22 PM |