In this tutorial I will use the TTS feature we are adding to Word 2007 to teach you how to add TTS to Word 2007. Because Youtube video descriptions do not allow "Greater than symbols the greater than symbol in the code below has been replace with #. When you copy and paste it into the macro as instructed by the video make sure you replace the # with the "greater than" symbol or SHIFT+.
Option Explicit
Dim speech As SpVoice
Dim i As Integer
Sub startTTS()
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 stopTTS()
On Error Resume Next
speech.Speak vbNullString, SVSFPurgeBeforeSpeak
Set speech = Nothing
i = 0
End Sub
Sub pauseTTS()
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
lol you su---. Just drops off for speaking. lol Darn you messed up voice issues. :) I wonder if you can get any patches.
DryBONESreborn 1 month ago
got it work excellent
ottivadkrsr 1 month ago
any way to get all the code in one file?
ottivadkrsr 1 month ago
mine says sintax error any help?
fish25pizza 1 month ago
It worked.....woot! super stoked!
TonyJeffers 1 month ago
I've tried this on Office 2010 and it works. (I know, there is a speak button available but there is no pause button). As was said before remember to delete the underlines signs and to put [speech.Speak ActiveDocument.Range(0, ActiveDocument.Characters.Count).Text, SVSFlagsAsync + SVSFPurgeBeforeSpeak] in one single line (without the [ ] ) and everithing works fine.
emnog 2 months ago
CultureShockSix 3 months ago
frm were do you get the text in 3:34? pls reply
hassanm97 3 months ago
I need help. it says compile error then highlights " speech.Speak ActiveDocument.Range(0, _ ActiveDocument.Characters.Count).Text, _ SVSFlagsAsync + SVSFPurgeBeforeSpeak" (quotes were not included in the highlighted part.) did i copy it worng or something?
please help
IronHide1232 3 months ago
It worked. It really worked. It did take some fooling around with it, probably more like and hour but I finally got it to work.
Thank you, Thank you, Thank you :o)
I'm an author and just bought a new computer. I use this feature of MS Word every single day and I'm glad I don't have to upgrade to MS 2010 just to use it.
You Rock :o)
tdla08 4 months ago