Vertical scroll on long image

C

Chris Watts

I have adapted some VBA code originally written by Bill Dilworrh (many
thanks to you Bill) that achieves pretty much what I need. The code is
below - and it works, even if rather slowly, in PPT 2007.

I wish to add some code so that I can interupt the scrolling with a mouse
click - and then restart it with another mouse click..
When I add the commented-out line
If MouseButtons.Left = True Then GoTo Pause
all that happens is that the code runs and moves the image up only one step
and then stops with no action from me. What am I doing wrong?
cheers
Chris

======================
Sub MoveUp(oShp As Shape)

'Determine the endpoint for the motion.
'In this case when the bottom edge of the image lines _
up with starting top of the image.
Endpoint = oShp.Top - oShp.Height

'Define amount to move image
Shift = 20
Offset = 475

While oShp.Top > Endpoint + Offset

'Move the picture a little upwards
oShp.Top = oShp.Top - Shift

'Re-render the screen
DoEvents

' If MouseButtons.Left = True Then GoTo Pause

'Loop back if not done
Wend

Pause:
End Sub
==========================
 
C

Chris Watts

I derived it from something a read on a web posting (not here) - clearly
from what you say it is not correct!
What is the native expressing for capturing a mouse-click event?
cheers
Chris
 
C

Chris Watts

Nope. Doesn't work for me. I have compressed the file down to 395KB at
25dpi - and I cannot get it to work as you have.

Chris

From the trials that I have done it seems as if there is a file size limit
of between 435KB and 465KB, on the basis that 435KB worked and 465KB
didn't! I guess the limit is around 450KB - maybe.

Brian.
 
C

Chris Watts

Is there one for capturing the pressing of a specific key? I can work with
that.
cheers
Chris
 
C

Chris Watts

Thanks Steve.
A trip down memory lane ahead! - the last time I used a Windows API was with
Windows 3.1
cheers
Chris
 
C

Chris Watts

Thanks for that Brian.
Your file runs just fine, with full length crawl-in, when I run it on my
machine using PPT2007.
If I use the PPT facility to substitute my (about 400KB) file then that too
runs just fine.
But if I create a new slide, add my file and add crawl-in then it is
truncated at the top!

Very odd indeed!
cheers
Chris

Hello, Chris,

I've attached the crawl-in PP2003 file. Just a single to show it.
It works on my PP20003.

Regards,

Brian.
 
C

Chris Watts

Further to this, Brian.
It seems as if it is not so-much file-size related but width related. I
gradually decreased the width of my picture from full screen (25.4 cm) -
when it fell below 24cm then everything worked.

It works for crawl-in but not for credit where truncation seems to take
effect.

cheers
Chris
 
C

Chris Watts

Many thanks Steve.
I have succeeded and now have a macro that will scroll up a long image
(within the limits of its original top position and the bottom of the
screen) and will allow the scroll to be paused and resumed with key-presses.
I will happily post it here if you think it might be of wider interest..

cheers
Chris
 
C

Chris Watts

Happy for you to add it to the PPT FAQ.
Trying now to add a backup feature to it but having trouble with variable
scope.

Code below.
cheers
Chris
====================
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long)
As Integer
Private Const KEY_PRESSED As Integer = &H1000

Sub MoveUp(oShp As Shape)
'Scroll an image upwards within the limits of its _
original top point and the bottom of the screen
'Includes provison for stopping and restarting the scroll _
Q key to Halt; R key to Resume.

'Determine the endpoint for the motion.
'In this case when the bottom edge of the image lines _
up with starting point for the top of the image.
Endpoint = oShp.Top - oShp.Height

'Defines the bottom of the screen where the bottom of the imgae should
stop
Offset = 475

'Define amount to move image each time
Shift = 20

While oShp.Top > Endpoint + Offset

'Move the picture a little upwards
oShp.Top = oShp.Top - Shift

'Re-render the screen
DoEvents

'Pause scrolling on pressing Q key
If GetKeyState(vbKeyQ) And KEY_PRESSED Then PauseMove

'Loop back if not done
Wend
End Sub

Sub PauseMove()
PauseMore:
'Resume scrolling on pressing Q key
If GetKeyState(vbKeyR) And KEY_PRESSED Then GoTo PauseEnd

DoEvents
GoTo PauseMore
PauseEnd:
End Sub
====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top