Browse » Home
Tuesday, August 27, 2013
How to Turn on Text to Speech for Word 2007
Add Speech Reference
1. Start the Microsoft Visual Basic Editor from within Word by pressing Alt+F11 keys. Click the 'Tools' menu and then select 'References.' On the list marked 'Available References,' scroll until 'Microsoft Speech Object Library' is selected. Click the check box next to this listing. Click 'OK.'
2. Add a new module by clicking 'Create a New Module' on the Microsoft Visual Basic Editor. Select the 'Name' field and enter 'TextToSpeech.' In the 'Macro' command area, paste the following code:Dim speech as SpVoiceSub SpeakText()On Error Resume NextSet speech = New SpVoiceIf Len(Selection.Text) > 1 Then 'speak selectionspeech.Speak Selection.Text, _SVSFlagsAsync + SVSFPurgeBeforeSpeakElse 'speak whole documentspeech.Speak ActiveDocument.Range(0, ActiveDocument.Characters.Count).Text, _SVSFlagsAsync + SVSFPurgeBeforeSpeakEnd IfDoDoEventsLoop Until speech.WaitUntilDone(10)Set speech = NothingEnd SubSub StopSpeaking()'Based on a macro by Mathew Heikkila'used to interrupt any running speech to textOn Error Resume Nextspeech.Speak vbNullString, SVSFPurgeBeforeSpeakSet speech = NothingEnd Sub
3. Right-click on the Word 2007 toolbar. From the list, select 'Customize Quick Access Toolbar.' Click 'Add Macro' and choose the newly created 'TextToSpeech' macro. Click 'Add' and then 'OK.' This toolbar button will now turn text to speech on and off as needed.