troubleshooting Question

Start VBA Routing in Powerpoint on Slide Load

Avatar of Paul Cahoon
Paul Cahoon asked on
2 Comments1 Solution10 ViewsLast Modified:
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
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
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
    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.
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros