Results 1 to 7 of 7

Thread: Implementing a Timer on a Slide using VBA

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,096
    Location
    Using API calls is not a good idea if you are not a competant programmer. I wouldn't go there. The sleep API will prevent anything else happening. You could use the SetTimer API but that is even more tricky to use properly.

    Also you should credit the author (Shyam Pillai) when you post his code.

    If you insist though you could try this:

    #If VBA7 Then
        ' allows for 64 bit
        Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    #Else
        Public Declare  Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    #End If
    
    Sub Tmr()
        Dim TMinus As Integer
        ' Countdown in seconds
        TMinus = 10
        With ActivePresentation.Slides(1).Shapes(1)
            Do While (TMinus > -1)
                ' Suspend program execution for 1 second (1000 milliseconds)
                Sleep 1000
                TMinus = TMinus - 1
                .TextFrame.TextRange = CStr(TMinus + 1) & "Secs"
                ' Very crucial else the display won't refresh itself
                DoEvents
            Loop
        End With
    End Sub
    If you want a timer running across the opresentation I would search for a free windows desktop timer. Most of these will run in front of your presentation.
    Last edited by John Wilson; 05-29-2011 at 03:29 AM.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •