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.
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.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
- 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.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 = NothingEnd Sub
- 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.
REFERENCES
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:'기타' 카테고리의 다른 글
2007 Office Fluent Ribbon을 사용자 지정 (개발자 대상) (2부) (0) | 2011.04.05 |
---|---|
2007 Office Fluent Ribbon을 사용자 지정 (개발자 대상) (1부) (0) | 2011.04.05 |
Using RibbonX with C++ and ATL (0) | 2011.04.03 |
COM Add-In을 통해 2007 Office Fluent Ribbon에 리소스 링크 추가하기 (0) | 2011.04.02 |
Customizing the Office (2007) Ribbon User Interface for Developers (Part 1 of 3) (0) | 2011.04.02 |