Use of SAPI Voice When Opening Workbooks

  • Thread starter Thread starter golf4
  • Start date Start date
G

golf4

Hi, everyone -

After speaking with several people, including Jake (Thanks), a
suggestion was made to try and use the SAPI built-in voice to speak in
Excel rather than wav files. I've included some test code below:

Sub test()
Dim s As Object
Set s = CreateObject("SAPI.SpVoice")
s.Speak "Greetings. How are you?"
Set s = Nothing
End Sub

I'm currently using Excel 2000, which, I guess, is limited to only one
voice. I had to do the Tools - References to Microsoft Speech Object
Library and it works.

If anyone has tried this, I'm wondering:

[1] is there a way to modify the code so that I could insert it by way
of a Workbook_Open placement and the voice would announce the name of
the file?

[2] Has anyone had any success in playing with this aspect so that the
voice sounds more "normal" rather than the typical computer voice?

Thanks so much for the help,

Golf
 
Hi Golf,

For question 1, you can use something like the following:

Private Sub Workbook_Open()
Dim s As Object
Set s = CreateObject("SAPI.SpVoice")
s.Speak Me.Name
Set s = Nothing
End Sub

Question 2, you got me.... It would be interesting to find out!
I'm sure some of the gurus will enlighten us.

Good luck

Rocke
 
No real help for your voice question, except to say SAPI is very tricky
to use directly and versions 4 and 5 are very different.

I recommend trying to install and choose voices outside Excel.

I do, however, have a comment on your code.

If you're sticking with Excel 2000 and don't need backward
compatibility, you shouldn't need the SAPI references at all

Application.Speech.Speak "Greetings. How are you?"
 
But that speech stuff was added in xl2002--not xl2k.

Steve said:
No real help for your voice question, except to say SAPI is very tricky
to use directly and versions 4 and 5 are very different.

I recommend trying to install and choose voices outside Excel.

I do, however, have a comment on your code.

If you're sticking with Excel 2000 and don't need backward
compatibility, you shouldn't need the SAPI references at all

Application.Speech.Speak "Greetings. How are you?"
Hi, everyone -

After speaking with several people, including Jake (Thanks), a
suggestion was made to try and use the SAPI built-in voice to speak in
Excel rather than wav files. I've included some test code below:

Sub test()
Dim s As Object
Set s = CreateObject("SAPI.SpVoice")
s.Speak "Greetings. How are you?"
Set s = Nothing
End Sub

I'm currently using Excel 2000, which, I guess, is limited to only one
voice. I had to do the Tools - References to Microsoft Speech Object
Library and it works.

If anyone has tried this, I'm wondering:

[1] is there a way to modify the code so that I could insert it by way
of a Workbook_Open placement and the voice would announce the name of
the file?

[2] Has anyone had any success in playing with this aspect so that the
voice sounds more "normal" rather than the typical computer voice?

Thanks so much for the help,

Golf
 
Apologies,

Dave's quite right. My memory's terrible at the moment, so I should have
checked befor posting.

Dave said:
But that speech stuff was added in xl2002--not xl2k.

<snip>
 
Hi, guys -

Thanks for the responses. I appreciate the help.

Continuing to experiment, instead of the using "the voice" in opening
the workbook itself, I went ahead and inserted the code into my splash
screen to run simultaneously with the splash:

Private Sub UserForm_Activate()
Application.ScreenUpdating = True
DoEvents

Dim s As Object
Set s = CreateObject("SAPI.SpVoice")
s.Speak "hi rick??? welcome to" & ThisWorkbook.Name
Set s = Nothing

Application.OnTime Now + TimeValue("00:00:02"), "KillTheForm"
End Sub

Seems to work really well. I threww a couple question marks, in the
code, because that seems to help with the voice's inflection (at least
a little).

Steve -

I know I have Excell 2000 at home (where I do most of my
"development"), but I can never remember the version we have at work.
I believe it is also 2000. I'll have to check it out on Monday
morning. I'll also check out the Microsoft SAPI stuff. The thing I'd
be concerned about is, if I were to install additional voices, they
would only be installed on my machine at home, right? Not exactly a
systems person (CAN YOU TELL???), I think I would have to install
extra stuff on the work computers as well. With all the viruses and
incompatability issues out there, we're real hesitant about installing
any "extra" stuff - especially for this purpose. I'll check it out
though.

Thanks for the help,

Golf
 
SORRY FOR THE SPELLING ERRORS..... PREVIEW, PREVIEW, PREVIEW.... UUUGGG!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top