Microsoft KB Archive/277808

= XL2002: &quot;Run-time Error 1004&quot; When You Attempt to Use Text to Speech in Macro =

Article ID: 277808

Article Last Modified on 1/29/2007

-

APPLIES TO


 * Microsoft Excel 2002 Standard Edition

-



This article was previously published under Q277808



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



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



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 (&quot;Hello&quot;) handler: If Err.Number = 1004 Then MsgBox &quot;This macro requires Text to Speech to be installed.&quot; End If End Sub



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.

