• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Application.ontime.

anup47

Member
Function Speak(c As Boolean, s As String)

If c Then Application.Speech.Speak s

Speak = c

End Function


This function speaks when used for lets say a1>a2, then speak b1, then we write =speak(a1>a2,b1)

now my problem is every time a1 will change and becomes greater than a2, it will speak b1. I want to make sure that it repeats b1 at least after 30 seconds. (or the time which i'll mention).

Can some one suggest me, how can application.ontime help me do this.

I've used application.ontime for macros, but not for defined function.

with regards

Anup
 

JP

New Member
How about this:


Function Speak(c As Boolean, s As String, t As Long)


Dim currenttime As Date


currenttime = Now


If c Then

Do Until currenttime + TimeValue("00:00:" & t) <= Now

Loop

Application.Speech.Speak s

Speak = c

End If

End Function


Call the function like this, specifying the value (in seconds) you want to wait before hearing the value in B1:


Sub test()


Call Speak(Range("A1").Value > Range("A2").Value, Range("B1").Value, 10)


End Sub
 

anup47

Member
Thank you very much for your reply. Its working up to my expectations.


I just want one more thing that for the first time it should speak as soon as my a1 becomes > a2. and if the a1 and a2 values keeps changing again and again and a1 again becomes > a2 then it should speak after a certain time, as your vba helps to do.


with regards

Anup
 
Top