C
Chris Watts
I am having problems with what I think is a variable scope problem in a VBA
macro for PPT 2007 under Windows XP that I am writing - code is at the end
of this message.
I wish to add some code containing the line
oShp.Top = oShp.Top - Shift
within the procedure PauseMove().
Naturally it works within the procedure in which these variables are
declared, namely MoveUp().
I have tried declaring both oShp and Shift as Module-wide and as Public -
but still neither variable seems to be recognised within PauseMove.
What am I doing wrong?
Advice welcomed.
TIA
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
====================================================
"Steve Rindsberg" <[email protected]
macro for PPT 2007 under Windows XP that I am writing - code is at the end
of this message.
I wish to add some code containing the line
oShp.Top = oShp.Top - Shift
within the procedure PauseMove().
Naturally it works within the procedure in which these variables are
declared, namely MoveUp().
I have tried declaring both oShp and Shift as Module-wide and as Public -
but still neither variable seems to be recognised within PauseMove.
What am I doing wrong?
Advice welcomed.
TIA
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
====================================================
"Steve Rindsberg" <[email protected]