Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Clock on powerpoint presentation

Posted on 2011-05-05
12
Medium Priority
?
919 Views
Last Modified: 2012-05-11
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!
0
Comment
Question by:scifo_dk
  • 6
  • 4
  • 2
12 Comments
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 35696895
How about ClocX - not in PP but will display time properly: http://www.clocx.net/
0
 
LVL 6

Author Comment

by:scifo_dk
ID: 35696917
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
 
LVL 6

Author Comment

by:scifo_dk
ID: 35696931
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 35701837
How do  you call the TimerOnOff Sub from your powerpoint presentation and which version of PowerPoint are you using?
0
 
LVL 6

Author Comment

by:scifo_dk
ID: 35705349
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
 
LVL 23

Expert Comment

by:JSRWilson
ID: 35716405
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
 
LVL 6

Author Comment

by:scifo_dk
ID: 35719788
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
 
LVL 23

Accepted Solution

by:
JSRWilson earned 2000 total points
ID: 35719938
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
 
LVL 6

Author Comment

by:scifo_dk
ID: 35720100
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
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 35720983
Hmm, I sort of suggested an external clock :)
0
 
LVL 6

Author Comment

by:scifo_dk
ID: 35721050
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
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 35721579
N/P :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
Progress
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question