hawk
06-11-2008, 05:49 PM
the scrolling of the document is to be controlled by the macro
at the moment it scrolls with hesitation due to the api call to sleep()
what I would like to do is smooth the scroll action
heres the code
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub PScroller()
'set counter n to documnet len'
n = ActiveDocument.Paragraphs.Count
'setup Document
ActiveWindow.ActivePane.View.Zoom.Percentage = 130
ActiveWindow.ActivePane.DisplayRulers = False
ActiveDocument.FormattingShowParagraph = False
ActiveDocument.ShowSpellingErrors = False
ActiveDocument.ShowGrammaticalErrors = False
MsgBox "Marco is ready to run, click on ok to continue", vbOKOnly
'Main loop. controls how many times scrolled
For a = 0 To 9 ' loops 10 times
'increments scroll
Do
ActiveWindow.ActivePane.VerticalPercentScrolled = i
' 1000 of a secound, pauses loop
Sleep (1)
i = i + 1
Loop While n > i
'Return to top of page and start again. reset i for next loop
Selection.HomeKey Unit:=wdStory
i = 0
Next a
MsgBox "Marco run finsihed", vbOKOnly
'reset defaults
ActiveWindow.ActivePane.DisplayRulers = True
ActiveDocument.ShowSpellingErrors = True
ActiveDocument.ShowGrammaticalErrors = True
End Sub
Im new to this so any help would be good
at the moment it scrolls with hesitation due to the api call to sleep()
what I would like to do is smooth the scroll action
heres the code
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub PScroller()
'set counter n to documnet len'
n = ActiveDocument.Paragraphs.Count
'setup Document
ActiveWindow.ActivePane.View.Zoom.Percentage = 130
ActiveWindow.ActivePane.DisplayRulers = False
ActiveDocument.FormattingShowParagraph = False
ActiveDocument.ShowSpellingErrors = False
ActiveDocument.ShowGrammaticalErrors = False
MsgBox "Marco is ready to run, click on ok to continue", vbOKOnly
'Main loop. controls how many times scrolled
For a = 0 To 9 ' loops 10 times
'increments scroll
Do
ActiveWindow.ActivePane.VerticalPercentScrolled = i
' 1000 of a secound, pauses loop
Sleep (1)
i = i + 1
Loop While n > i
'Return to top of page and start again. reset i for next loop
Selection.HomeKey Unit:=wdStory
i = 0
Next a
MsgBox "Marco run finsihed", vbOKOnly
'reset defaults
ActiveWindow.ActivePane.DisplayRulers = True
ActiveDocument.ShowSpellingErrors = True
ActiveDocument.ShowGrammaticalErrors = True
End Sub
Im new to this so any help would be good