2
votes

I have a code that acts as a countdown timer(up to three timers on one sheet), and several actions occur while the timer is active. Everything is working fine right now. When any of the timers hit 0 the following snippet of code is run:

If Sheets("Sheet1").Range("C8").Interior.Color = 255 Or Sheets("Sheet1").Range("G8").Interior.Color = 255 Or Sheets("Sheet1").Range("K8").Interior.Color = 255 Then

Beep
Application.Speech.Speak ("Part is done")
Beep

Call AlertTIMER
Else
Exit Sub
End If

The AlertTIMER sub that is called from the snippet above runs Application.Wait, creating a 3 second pause between when it was last called and when it can be called next. The reason I have included the wait function is because while Application.Speech is running I'm unable to complete any other actions (such as clicking the "Stop" command button which terminates the Alert sub).

Is there a way to allow command buttons to be pressed while Application.Speech is active so I can remove the Application.Wait function? Or do I need to keep my workaround of Application.Wait?

I have tried using DoEvents by placing it before the first beep but it did not work.

3
Also, if you would like me to supply other portions of the code or further explain, I can... Just there's a lot going on so I tried to be concise.Dimitri M
I'm not really clear with what you're trying to do. If you're just trying to break the application.speech.speak while executing, You can ctrl+break.Raystafarian
Okay, so the Alert sub (Beep "Part is done" Beep) is going off, and then there is a 3 second pause (due to Application.Wait). This pause allows for someone to click a commandbutton (Stop) which will cause the Alert Sub to stop being triggered. If they don't, then after the 3 seconds have expired, the Alert sub is called again. If I do not include the pause (which Ideally I would like to remove) , then it is impossible to click the commandbutton (stop) while the Alert sub is active. I'm looking for a way to be able to execute actions while the sub Alert is active (Beep "Part is done" Beep).Dimitri M
I do not want to have to use ctrl+break as sometimes I will be executing an action but want to the Alert sub to continue. One example of this is there are multiple timers. So if two are triggering the alert, I want to be able to click stop on the one, and then complete an action... while the alert sub continues on since the second stop was no clicked. ctrl+break would jump me out of both. Also, I would like to avoid ctrl+break as i dont want to have to click something on the keyboard and I dont believe sendkeys is considered reliable - so I dont want to include it as part of the code.Dimitri M

3 Answers

1
votes
0
votes

you can add the instruction DoEvents it will allow the OS to check any other interaction like clicks... check for some tutorials about this

0
votes
Application.Speech.Speak ("Part is done",true)

that should enable you to maintain the functionality with the workbook