Clock on powerpoint presentation

Hi Experts.

I'm creating a powerpoint presentation, that should serve as an infoboard in the welcoming area. I'm using office 2007.

I wan't to have a clock on all the pages, that states the current time in (HH:mm) format. And that should update automaticly.

The following code (found online) works on the first sheet, but somestimes crashes powerpoint :(

Can you either rewite it, or point me in the right direction? Thanks.

Btw. I'm not interested in the non-free solutions out there.

Thanks alot in advance!
LVL 6
scifo_dkAsked:
Who is Participating?
 
JSRWilsonCommented:
Events are pretty much unchanged in 2010 ( ie difficult to program)

Source of your code is Shyam Pillai
Office Tips

If you don't have a very good understanding of the setTimer API I wouldn't go there, it's very prone to crashing when used to call an address as Shyam does. Also you would need to alter the code to point at the curret slide in show mode

SlideShowWindows(1).View.Slide
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
How about ClocX - not in PP but will display time properly: http://www.clocx.net/
0
 
scifo_dkAuthor Commented:
gerwinjansen ->
Maybe I should have put it more precisely :)

It will also display other stuff like news, graphs and stuff. So it has to be in pp.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
scifo_dkAuthor Commented:
Forgot to include the code I found:

Option Explicit

'API Declarations

Declare Function SetTimer Lib "user32" _
                            (ByVal hwnd As Long, _
                             ByVal nIDEvent As Long, _
                             ByVal uElapse As Long, _
                             ByVal lpTimerFunc As Long) As Long

Declare Function KillTimer Lib "user32" _
                            (ByVal hwnd As Long, _
                             ByVal nIDEvent As Long) As Long

 

' Public Variables

Public SecondCtr As Date
Public TimerID As Long
Public bTimerState As Boolean


Sub TimerOnOff()

If bTimerState = False Then
    TimerID = SetTimer(0, 0, 1000, AddressOf TimerProc)
    If TimerID = 0 Then
        MsgBox "Unable to create the timer", vbCritical + vbOKOnly, "Error"
        Exit Sub
    End If
    bTimerState = True
Else
    TimerID = KillTimer(0, TimerID)
    If TimerID = 0 Then
        MsgBox "Unable to stop the timer", vbCritical + vbOKOnly, "Error"
    End If
    bTimerState = False
End If
End Sub

 

' The defined routine gets called every nnnn milliseconds.

Sub TimerProc(ByVal hwnd As Long, _
                    ByVal uMsg As Long, _
                    ByVal idEvent As Long, _
                    ByVal dwTime As Long)

SecondCtr = Format(Now(), "HH:mm:ss")
ActivePresentation.Slides(1).Shapes(2).TextFrame.TextRange.Text = CStr(SecondCtr)

End Sub

Open in new window


0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
How do  you call the TimerOnOff Sub from your powerpoint presentation and which version of PowerPoint are you using?
0
 
scifo_dkAuthor Commented:
gerwinjansen ->
I can assign the macro to a button, or start it manually via the VB-editor. But if an error occurs, the timer still continues, and Powerpoint crashes.

I'm using the 2007 version :)
0
 
JSRWilsonCommented:
You really should at least credit the author of the code!
the setTimer API will run even if the code crashes and try to call the TimerProc. If it's not available it will crash.

There are plenty of desktop clocks that will play on top of PowerPoint (free) and this would be much safer
0
 
scifo_dkAuthor Commented:
JSRWilson ->
Of cause. However, it's been some time since I found the code, so I cannot remember where.

Yes, I could use some external clock to overlay the presentation, nowever I was hoping to keep everything inside the presentation.

Do you know if PowerPoint 2010 has events in VBA?
0
 
scifo_dkAuthor Commented:
JSRWilson ->

Thanks for posting the link.

I don't, so I will see if some external clock suits my need instead.

Thanks for your help!
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Hmm, I sort of suggested an external clock :)
0
 
scifo_dkAuthor Commented:
gerwinjansen ->

I know, but JSRWilson provided me with what I asked for. I wanted to use the code inside a presentation, but it had some errors.

The question was regarding the code, or another PP solution.

Hope you understand my reason :)
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
N/P :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.