Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2002: "Run-time Error 1004" When You Attempt to Use Text to Speech in Macro


View products that this article applies to.

Symptoms

When you attempt to use the Text to Speech feature in a macro, you receive an error message similar to the following:
Run-time error '1004':

Application-defined or object-defined error

↑ Back to the top


Cause

This error message occurs if the Text to Speech feature for Excel is not installed on the computer.

↑ Back to the top


Workaround

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.

Sample Code

The following sample code demonstrates how to use error handling to bypass the run-time error that occurs if Text to Speech is not installed:
Sub SayHello()
    
    On Error GoTo handler
    Application.Speech.Speak ("Hello")
    
handler:
    If Err.Number = 1004 Then
        MsgBox "This macro requires Text to Speech to be installed."
    End If
End Sub
				

↑ Back to the top


More information

By default, the Text to Speech feature is not installed when you install Excel; it is installed the first time that you attempt to use the feature. Therefore, if you want to use Text to Speech in a custom solution, your program must make sure that Text to Speech is already installed on the target computer.

NOTE: Microsoft Excel 2002 is the only program in the Microsoft Office suite that has Text to Speech functionality. To use Text to Speech in other Office programs, you must use an Excel object.

↑ Back to the top


References

For additional information about how to use an Excel object for Text to Speech, click the article number below to view the article in the Microsoft Knowledge Base:
287120 OFFXP: How to Automate Excel to Use Text to Speech from Another Office Program

↑ Back to the top


Keywords: KB277808, kbprb, kberrmsg, kbenablesight, kbenable

↑ Back to the top

Article Info
Article ID : 277808
Revision : 6
Created on : 1/29/2007
Published on : 1/29/2007
Exists online : False
Views : 317