Article ID: 287120
Article Last Modified on 10/23/2006
APPLIES TO
- Microsoft Excel 2002 Standard Edition
- Microsoft Outlook 2002 Standard Edition
- Microsoft PowerPoint 2002 Standard Edition
- Microsoft Word 2002 Standard Edition
This article was previously published under Q287120
IN THIS TASK
SUMMARY Use Text to Speech in PowerPoint
- Insert a Module into a PowerPoint Presentation
- Add a Reference to Excel 10 Object Library
- Sub Procedure to Automate Excel Text to Speech from PowerPoint
SUMMARY
This step-by-step article explains how you can use the Text to Speech functionality of Microsoft Excel in other programs, including Microsoft Word, Microsoft PowerPoint, and Microsoft Outlook.
Microsoft Excel is the only Microsoft Office XP program that has built-in Text to Speech (TTS) capabilities. This article explains how you can use OLE Automation to programmatically access the Excel object model and use the Text to Speech functionality in other programs.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
back to the top
Use Text to Speech in PowerPoint
The following example uses the Excel object model to access Text to Speech from a PowerPoint presentation. This procedure demonstrates how to reference and create an Excel object in order to use the Speech object.
back to the top
Insert a Module into a PowerPoint Presentation
- Open a PowerPoint presentation.
- Press ALT+F11 to start the Visual Basic Editor.
- On the Insert menu, click Module.
- Type or copy and paste into the module the sample code that appears later in this section.
Add a Reference to Excel 10 Object Library
- In the Visual Basic Editor, point to References on the Tools menu.
- Under Available References, click to select the Microsoft Excel 10.0 Object Library check box, and then click OK.
Sub Procedure to Automate Excel Text to Speech from PowerPoint
The following example assumes that your PowerPoint presentation has two slides.
Sub demoTTS() 'Declare and create an Excel object. Dim XL As Excel.Application Set XL = CreateObject("Excel.Application") ActivePresentation.SlideShowSettings.Run With SlideShowWindows(1).View 'The following is said on the first slide: XL.Speech.Speak "Welcome to my presentation." 'Change to slide 2, and then say the following two sentences: .Next XL.Speech.Speak "This is an example of how to create an Excel Application object." XL.Speech.Speak "We can use Excel's object model to invoke Text to Speech." 'Close the Excel object and set the object to nothing. XL.Quit Set XL = Nothing 'Exit the slideshow. .Exit End With End Sub
NOTE: PowerPoint security is set at high by default. Unsigned Visual Basic macros do not run in this setting. Change the macro security level to medium by following these steps:
- On the Tools menu, point to Macro, and then click Security.
- On the Security Level tab, click to select Medium, and then click OK.
- On the File menu, click Exit to quit PowerPoint.
NOTE: You must quit and restart PowerPoint for the security level change to take effect.
Use Text to Speech in Word
The following example uses the Excel object model to access Text to Speech from a Word document. This procedure demonstrates how to reference and create an Excel object in order to use the Speech object.
back to the top
Insert a Module into Word
- Open a Word document.
- Press ALT+F11 to start the Visual Basic Editor.
- On the Insert menu, click Module.
- Type or copy and paste into the module the sample code that appears later in this section.
Add a Reference to Excel 10 Object Library
- In the Visual Basic Editor, point to References on the Tools menu.
- Under Available References, select the Microsoft Excel 10.0 Object Library check box, and then click OK.
Sub Procedure to Automate Excel Text to Speech from Word
The following example assumes that you type text in your Word document and then select the text before you run the Sub procedure.
Sub TTS() 'Declare and create an Excel object. Dim XL_tts As Excel.Application Set XL_tts = CreateObject("Excel.Application") XL_tts.Speech.Speak Selection XL_tts.Quit Set XL_tts = Nothing End Sub
NOTE: Word security is set at high by default. Unsigned Visual Basic macros do not run in this setting. Change the macro security level to medium by following these steps:
- On the Tools menu, point to Macro, and then click Security.
- On the Security Level tab, click to select Medium, and then click OK.
- On the File menu, click Exit to quit Word.
NOTE: You must quit and restart Word for the security level change to take effect.
back to the top
REFERENCES
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
277808 XL2002: "Run-time Error 1004" When You Attempt to Use Text to Speech in Macro
For additional information about getting help with Visual Basic for Applications, click the following article number to view the article in the Microsoft Knowledge Base:
163435 Programming resources for Visual Basic for Applications
Additional query words: OfficeKBHowTo inf
Keywords: kbautomation kbenablesight kbhowtomaster KB287120