0

I have a PowerPoint presentation in Kiosk Mode. In normal conditions during the presentation when user clicks the wrong option the shape's background fills red and plays a buzzer sound. If the user clicks the correct answer the background is filled with green color and a sound is played.

I wish to run a count down timer using VBA Macro which is implemented through a "Do Until Loop". I am using a "DoEvents" command within the loop but that is not helping properly. While the timer is running I can click on the shapes, the sound is played as desired but the animations don't work i.e. the wrong shape doesn't get filled with red background or the correct shape doesn't get filled with green background. However, when the timer is finished I can select objects as desired and wrong options get filled with red and so on.

Sub CountDown(ByVal timer_value As Integer, ByVal Wn As SlideShowWindow)        
            
    Dim future As Date
    Dim curr_slide As Integer
    curr_slide = Wn.View.CurrentShowPosition
    future = DateAdd("s", timer_value, Now())
            
    Do Until future <= Now()
        DoEvents
        ActivePresentation.Slides(curr_slide).Shapes("Pentagon").TextFrame.TextRange = Format(future - Now(), "s")             
    Loop
        
    'This shows the Time is Up picture.
    ActivePresentation.Slides(curr_slide).Shapes("Time").Visible = True
    
End Sub

How can I resolve this issue of animations not responding?

Community
  • 1
  • 1
  • If you don't want that users can click or do anything while waiting why don't you use an [Application wait](https://stackoverflow.com/questions/1544526/how-to-pause-for-specific-amount-of-time-excel-vba) instead? If you only wish to display a timer, why don't you try adding a text box and displaying it there instead? – Sgdva Jan 18 '22 at 18:23
  • @Toddleson you might have see my code it does only two things inside the loop – Ehtisham Safdar Jan 19 '22 at 13:30
  • @Toddleson you might have see my code it does only two things inside the loop, 1. Update the counter 2. DoEvents Can you please explain which part should I split and suspend for some time. My count down timer is counting seconds so if I delay the execution for more than a second it will not update the timer properly. One more thing, when I try to use this **Application.OnTime** or **Application.Wait** in power point vba then I don't see these functions with Application object. How to enable these? – Ehtisham Safdar Jan 19 '22 at 14:53
  • PowerPoint doesn't have Application.OnTime or Application.Wait, so those won't help. One thing you might try is to put your countdown timer in a form which you launch *modelessly*. Your code in the timer form should include plenty of DoEvents statements so as not to hog the processor. – Steve Rindsberg Aug 17 '23 at 13:16

0 Answers0