Stopping a macro in slideshowwindows(1).view

E

eldon.l.lehman

Reference: previous post entitled: How to stop a macro on
SlideShowNextSlide event? by Brian ORielly April 2001

I would like to place a shape on slide1(action setting>run macro
"ExitStrategy()") and have it stop a running macro(action setting.run
macro "YourCurrentCode()") when the screen shows the desired color for
another shape on slide1.
Apparently the suggested code in this example is not correctly placed
in my code. Could you point me to the error?
Windows XP
PPT 2003

begin code ------
Public blnFlagExit As Boolean
Public pres As Presentation
Public oSld As Slide

Sub YourCurrentCode()
Set pres = ActivePresentation
Set oSld = pres.Slides(1)
Dim blnFlagExit As Boolean
blnFlagExit = False
'Does what it does and
'the following is in the code
'Works best inside a loop since it's visited
'frequently
Dim n As Integer
Do While n < 255
oSld.Shapes("Arm").Fill.ForeColor.RGB = RGB(n, 0, 0)
If blnFlagExit = True Then
Exit Sub
End If
SlideShowWindows(1).View.GotoSlide 1
'Rest of your code
n = n + 1
Loop
MsgBox "At the finish is equal to " & n
End Sub


Sub ExitStrategy()
'Attach this to a full frame no fill shape OnClick action
blnFlagExit = True
End Sub
end code ----

Thank you,
Eldon
 
S

Steve Rindsberg

What's it doing wrong that it shouldn't? Or what's it not doing that it
should? Hard to say what's wrong at this distance w/o knowing what's wrong
from where you sit. ;-)
 
S

Shyam Pillai

Hi Eldon,
You need a couple of changes in your routine:

Sub YourCurrentCode()

' Dim blnFlagExit As Boolean <- Delete this line.

Set pres = ActivePresentation
Set oSld = pres.Slides(1)
blnFlagExit = False
'Does what it does and
'the following is in the code
'Works best inside a loop since it's visited
'frequently
Dim n As Integer
Do While n < 255
oSld.Shapes(1).Fill.ForeColor.RGB = RGB(n, 0, 0)
If blnFlagExit = True Then
Exit Sub
End If

DoEvents <- Add this line

'SlideShowWindows(1).View.GotoSlide 1 <- Delete this line, if not necessary
for your refresh

'Rest of your code
n = n + 1
Loop
MsgBox "At the finish is equal to " & n
End Sub
 
E

eldon.l.lehman

The shape attached to the macro("ExitStrategy()") when clicked to stop
the macro("YourCurrentCode()") does not stop it, it continues to
completion.
 
E

eldon.l.lehman

That worked perfectly! "Do Events" opens up a new can of worms for me,
but I am glad to see an application of it.
Thank you
 

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