Microsoft Knowledge Base Email Alertz

KBAlertz.com: (287120) - 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...

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 287120 - Last Review: October 23, 2006 - Revision: 3.1

How to automate Excel Text to Speech in another Office program

This article was previously published under Q287120

On This Page

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.

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

  1. Open a PowerPoint presentation.
  2. Press ALT+F11 to start the Visual Basic Editor.
  3. On the Insert menu, click Module.
  4. 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

  1. In the Visual Basic Editor, point to References on the Tools menu.
  2. 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:
  1. On the Tools menu, point to Macro, and then click Security.
  2. On the Security Level tab, click to select Medium, and then click OK.
  3. 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

  1. Open a Word document.
  2. Press ALT+F11 to start the Visual Basic Editor.
  3. On the Insert menu, click Module.
  4. 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

  1. In the Visual Basic Editor, point to References on the Tools menu.
  2. 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:
  1. On the Tools menu, point to Macro, and then click Security.
  2. On the Security Level tab, click to select Medium, and then click OK.
  3. On the File menu, click Exit to quit Word.
NOTE: You must quit and restart Word for the security level change to take effect.

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
277808  (http://kbalertz.com/Feedback.aspx?kbNumber=277808/EN-US/ ) 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  (http://kbalertz.com/Feedback.aspx?kbNumber=163435/ ) Programming resources for Visual Basic for Applications

APPLIES TO
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Outlook 2002 Standard Edition
  • Microsoft PowerPoint 2002 Standard Edition
  • Microsoft Word 2002 Standard Edition
Keywords: 
kbautomation kbenablesight kbhowtomaster KB287120
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please