Let's suppose now it is 11h11min. It reads "ONE ONE" hours and "eleven" minutes, as in:
Sub TEST1()
Application.Speech.Speak "It is " & Hour(Now()) & " hours and " & Minute(Now()) & " minutes"
End Sub
However, the following reads "eleven" hours and "eleven" minutes
Sub TEST2()
Application.Speech.Speak "It is 11 hours and 11 minutes"
End Sub
On the contrary, it reads "ONE ONE" hours and "eleven" minutes, as in:
Sub TEST3()
Application.Speech.Speak "It is " & "11" & " hours and " & "11" & " minutes"
End Sub
How can I get it to read these numbers as words?
Approach via SpeakXML argument
Syntax
If you set the 3rd argument
SpeakXML
to True, you can use XML tags in your text string.The XML
<spell>
tag forces the voice to spell out all text, rather than using its default word and sentence breaking rules. All characters should be expanded to corresponding words (including punctuation, numbers, and so forth). Note that the<spell>
tag mustn't be empty and don't forget the closing tag</spell>
.Try to use the following with both variants of
11
:Code
Note/caveat
I'm using a central European language Version and your example did'nt speak out ONE ONE in my case, so maybe there is another local setting issue.
The Portuguese language has some interesting pronunciation challenges. We have, among other, the nasal "-ão" termination for words as in São Paulo. The -ão is pronounced almost like the -ow in "sow" and it means that while you pronounce the vowels, the air should come out partly from your nose. That being said ...
Application.Speech.Speak "Já são" & Hour(Now()) & "horas e 11 minutos"
--> reads "It is ONE ONE hours and ELEVEN minutes"Application.Speech.Speak "11"
--> reads "ELEVEN"Application.Speech.Speak "Já são" & "11" & "horas"
--> reads "It is ONE ONE hours"Application.Speech.Speak "Já sao" & Hour(Now())
--> reads "It is ELEVEN hours". Notice that the nasal -"ão" was removed in this case. So, the number pronunciation is in wordsApplication.Speech.Speak "Já são^" & Hour(Now())
--> reads "It is ELEVEN hours". Notice that the nasal -"ão" is now present and also there is a "^" sign positioned just afterwardsI don´t know why Excel behaves like that. But, problem solved :)
You need to create/modify the string to produce the results you want.
will repeat the same thing.
will do the same. Once you have decided what you want the computer to say, you can format/re-format the string to produce that result.
EDIT#1:
On my computer this:
also works as expected.
It looks like the concatenation needs to be performed first.