Text to speech

  • Thread starter Thread starter Rod
  • Start date Start date
R

Rod

My excel has text to speech, but I can't find the same thing in Word (XP).
Where is it hidden?

many thanks


Rod
 
Rod said:
My excel has text to speech, but I can't find the same thing in Word
(XP). Where is it hidden?

Not provided - and it's not in Word 2003 either


Mike Williams - Office MVP
http://www.mvps.org/

Please respond in the same thread on this newsgroup. Make sure you
include details of your application and Windows versions, and whether
or not you have included any service pack updates.
 
Thanks for your reply.
Do you happen to know if there is any logic behind that decision as the
other way around would have been more useful.
 
Rod said:
Thanks for your reply.
Do you happen to know if there is any logic behind that decision as
the other way around would have been more useful.

I think it was to help all those accountants who like to have columns of
figures read back to them. Personally I prefer Proust.

Mike Williams - Office MVP
http://www.mvps.org/

Please respond in the same thread on this newsgroup. Make sure you
include details of your application and Windows versions, and whether
or not you have included any service pack updates.
 
Re: getting Text to Speech to work in Word

The method described in the KB article mentioned above has you
starting up an Excel application to get speech. Here is a method to do
it just within Word:

The following applies to WordXP:
Go to the VBE (Alt+F11)
Add a reference in the normal project to Microsoft Speech Object
Library
(note: you must have installed the Speech portion of Excel for this
reference to be available.)
Create a new module
Insert the following code:
'Code Start =============================================
Dim speech As SpVoice

Sub SpeakText()
'
' Macro2 Macro
' Macro recorded 10/20/2003 by Mathew Heikkila
'
On Error Resume Next

Set speech = New SpVoice

If Len(Selection.Text) > 1 Then
'speak selection
speech.Speak Selection.Text, _
SVSFlagsAsync + SVSFPurgeBeforeSpeak
Else
'speak whole document
speech.Speak ActiveDocument.Range(1,
ActiveDocument.Characters.Count).Text, _
SVSFlagsAsync + SVSFPurgeBeforeSpeak
End If

Do
DoEvents
Loop Until speech.WaitUntilDone(10)

Set speech = Nothing
End Sub

Sub StopSpeaking()
'used to interupt any running speach to text
'Dim speech As New SpVoice
On Error Resume Next
speech.Speak vbNullString, SVSFPurgeBeforeSpeak
Set speech = Nothing
End Sub

'Code End ====================================================

Now all you need are two toolbar buttons or menu items that run the
macros.
The SpeakText macro will speak the current selection, or the entire
document if nothing is selected.
The StopSpeaking macro will stop it.

Hope this can help anyone else who was as frustrated as me that Excel
had this feature but not Word.

Yes, its crude regarding the error trapping and using a global
variable. If anyone has a cleaner way, please post a reply. The whole
reason for this was to be able to stop the speaking. Simply creating a
new voice object and setting the PurgeBeforeSpeak flag did not work.
If the ASync flag is not turned on the in the speaktext macro, you
have to wait for it to finish before you can do anything else in Word.

Matt
 
Back
Top