Dimitri M
Dimitri M

Reputation: 106

Allow Excel to execute actions while application.Speech.Speak is active

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.

Upvotes: 2

Views: 1879

Answers (3)

user29503
user29503

Reputation: 11

Application.Speech.Speak "Part is done", SpeakAsync:=True

Source: https://wellsr.com/vba/2016/excel/make-excel-talk-with-application-speech-speak-vba/

Upvotes: 1

Some Dude
Some Dude

Reputation: 1

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

that should enable you to maintain the functionality with the workbook

Upvotes: 0

Bas
Bas

Reputation: 1

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

Upvotes: 0

Related Questions