Text to speech in MS Word 2007
Below are the macros to enable TTS. These macros should be put into “normal.dot”, so it gets loaded along with MS word application.
Press Alt+F11 to goto macro editor and paste this code. You need to add three buttons to quick access tool bar. You can do this by clicking small downward arrow telling “Customize quick access toolbar” on the title bar of MS word where you will find save, undo and redo buttons. Select “More commands” in the dropdown menu to open “Word options” window. Select “Customize” on left hand menu and “Choose commands from” should be set to “Macros”. Add all three macros and this will create three buttons on the quick access tool bar. Now your MS word is TTS enabled.
Option Explicit
Dim speech As SpVoice
Dim i As Integer
Sub SpeakText()
On Error Resume Next
If i = 0 Then
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(0, _
ActiveDocument.Characters.Count).Text, _
SVSFlagsAsync + SVSFPurgeBeforeSpeak
End If
Else
If i = 1 Then
speech.Resume
i = 0
End If
End If
End Sub
Sub StopSpeaking()
On Error Resume Next
speech.Speak vbNullString, SVSFPurgeBeforeSpeak
Set speech = Nothing
i = 0
End Sub
Sub PauseSpeaking()
On Error Resume Next
If i = 0 Then
speech.pause
i = 1
Else
If i = 1 Then
speech.Resume
i = 0
End If
End If
End Sub
Source