Avatar of Paul Cahoon
Paul Cahoon
 asked on

Start VBA Routing in Powerpoint on Slide Load

I found a piece of code that creates a clock on a power point slide. All credit for this goes to The Tech Train Youtube channel.

My issue lies in the fact that in the video he is starting the code from an action button but I want to start it when the slide actually loads. I have been able to get it to start but when I do, it seems to freeze the slideshow in place and I can't proceed.

Here is the code for the clock:

Public clock As Boolean
Public currenttime, currentday As String

Sub Pause()
Dim PauseTime, start
PauseTime = 1
start = Timer
Do While Timer < start + PauseTime
DoEvents
Loop
End Sub

Sub StartClock()
clock = True
Do Until clock = False
On Error Resume Next
currenttime = Format((Now()), "h:mm:ss AM/PM")
'to remove am/pm comment the following line out
currenttime = Mid(currenttime, 1, Len(currenttime) - 3)
ActivePresentation.Slides(SlideShowWindows(1).View.CurrentShowPosition).Shapes("shpClock").TextFrame.TextRange.Text = currenttime
Pause
Loop
End Sub

Sub OnSlideShowPageChange(ByVal objectWindow As SlideShowWindow)
clock = False
ActivePresentation.Slides(SlideShowWindows(1).View.CurrentShowPosition).Shapes("shpClock").TextFrame.TextRange.Text = "--:--:--"
End Sub

Sub OnSlideShowterminate()
clock = False
End Sub

Open in new window

My issue is starting the clock. Here is the closest I've been able to get:

Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)
    If Wn.View.CurrentShowPosition = 2 Then
    StartClock
    End If
End Sub

Open in new window

My problem is that using this code, I cannot advance to the next slide or close the slideshow. The code works great if I attach it to an action button but I want it totally automatic.
VBA

Avatar of undefined
Last Comment
Paul Cahoon

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Fabrice Lambert

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Paul Cahoon

ASKER
Ok, thanks.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23