PDA

View Full Version : PowerPoint VBA prematurely exit loop slide show



pacecal
05-18-2019, 10:30 AM
If a textbox with the name "Textbox1" is present on a current slide a counter wil start.

But only when the counter has stopped you can navigate to another slide. How can i cancel prematurely the loop so i can navigate to another slide?


PublicSub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)

Dim t AsDate
Dim s As Shape

ForEach s In Wn.View.Slide.Shapes

If s.Name ="Textbox1"Then

t = DateAdd("s",10, Now())

DoUntil t < Now()

DoEvents

Wn.View.Slide.Shapes("Textbox1").TextFrame.TextRange.Text = Timer

Loop

EndIf

Next s

EndSub

John Wilson
05-18-2019, 01:27 PM
Not sure why you would do this but here's one way


Dim B_Stop As Boolean

Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)


Dim t As Date
Dim s As Shape
B_Stop = False
For Each s In Wn.View.Slide.Shapes
If s.Name = "TextBox1" Then
t = DateAdd("s", 10, Now())
Do Until t < Now()
If B_Stop = True Then Exit Do
DoEvents
Wn.View.Slide.Shapes("TextBox1").TextFrame.TextRange.Text = Timer
Loop
End If
Next s
End Sub


Sub stopper()
' have a button to run this
B_Stop = True
End Sub

pacecal
05-19-2019, 02:06 PM
i don't want to use a button. i'm looking for a way to navigate true slides (next/previous) without buttons.

John Wilson
05-19-2019, 10:14 PM
There's no way I know to jump out of the loop without a button.

BUT what is the purpose of the loop, Maybe you just do not need it.

pacecal
05-19-2019, 11:52 PM
why is the event OnSlideShowPageChange not responding during the loop? I really need the loop....

John Wilson
05-20-2019, 03:50 AM
Why would it. There is no page change.

You might want to try actually answering the question WHY you need the loop.

pispswarren
07-14-2019, 11:26 AM
When I run the macro, error message appears regardless of cursor being active or not. Do you have any idea how to fix it?time management game (https://play.google.com/store/apps/details?id=com.fme.cookit&hl=en)

pacecal
07-19-2019, 10:14 AM
Why would it. There is no page change.

You might want to try actually answering the question WHY you need the loop.

I want to show a countdown counter based on a specific algorithm with a specific purpose.