Link to home
Create AccountLog in
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
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.
Avatar of Fabrice Lambert
Fabrice Lambert
Flag of France image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Paul Cahoon
Paul Cahoon


Ok, thanks.