PowerPoint tips, hints and tutorials that will change your presentations for ever!



Custom Shows
vba code
Games for teachers
Flash Cards
Multiple Instances
PowerPoint 2007
Mail Merge
Random events
Set spellcheck language

Home buttonTutorial buttonContact buttonProducts button

PowerPoint Countdown to a Special Day

Lots of people have asked us for Add Ins to countdown automatically to a special day in a constantly looping presentation.

To do this "properly" means writing event traps to detact the slide changes and this is not easy but we have discovered a DIY way!

The code to add the countdown is fairly easy. In the example we are counting down to Christmas and adding the message to the current frontmost shape on Slide 1. Make sure this shape can contain text!

The code

Sub Countdown()
Dim thedate As Date
Dim daycount As Long
Dim Icount As Integer
Icount = ActivePresentation.Slides(1).Shapes.Count
'change to suit
thedate = "25/12/2015"
daycount = DateDiff("d", Now, thedate)
Select Case daycount
Case Is > 1
ActivePresentation.Slides(1).Shapes(Icount) _
.TextFrame.TextRange = daycount & " Days to go!"
Case Is = 1
ActivePresentation.Slides(1).Shapes(Icount) _
.TextFrame.TextRange = daycount & " Day to go!"
Case Else
ActivePresentation.Slides(1).Shapes(Icount) _
.TextFrame.TextRange = "It's here!"
End Select
End Sub

Don't know what to do with the code? See Here

This is the easy bit! The real problem is getting the code to run every time slide one shows. This will only work in a looping presentation.

This code detects the last slide showing and runs the first code to update the values on slide 1

Sub OnSlideShowPageChange(SW As SlideShowWindow)
If SW.View.Slide.SlideIndex = (ActivePresentation.Slides.Count) Then Countdown
End Sub

Don't try to run this code manually it will crash outside of a show.

There's a snag though this is a legacy method that goes back to version 97 and it is not really reliable. If you save, close and reopen it will usually fail.

You can fix this though

Add a control button from the Control toolbox (or any other item from here will work) You will need to go to Options > Customize ribbon and tick "DEVELOPER" to see this option.

Cotrol Toolbox

This kicks the code into working. You don't need to add code to the item and if you wish (probably) make it non visible in the selection pane.



Back to the Index Page


Articles on your favourite sport

Free Microsoft PowerPoint Advice, help and tutorials, Template Links
This website is sponsored by Technology Trish Ltd
© Technology Trish 2007
Registered in England and Wales No.5780175
PowerPoint® is a registered trademark of the Microsoft Corporation