Microsoft
Excel is the only Microsoft Office XP program that has
built-in text to Speech (TTS) capabilities. This tip explains how you can use
OLE Automation to programmatically access the Excel Object model and use the
Text to Speech functionality.
Speech
Method – Contains methods and properties that pertain to
speech.
Name
Description
|
Speak
Microsoft Excel plays back
the text string that is passed as an argument
|
Speak
Members – Contains methods and properties that pertain to
speech.
expression .Speak(Text, SpeakAsync, SpeakXML, Purge)
expression A
variable that represents a Speech object.
Parameters
Name
|
Required/Optional
|
Data
Type
|
Description
|
Text
|
Required
|
String
|
The
text to be spoken.
|
SpeakAsync
|
Optional
|
Variant
|
True will
cause the Text to be spoken asynchronously (the method will not
wait of the Text to be spoken). False will cause the Text to be spoken
synchronously (the method waits for the Text to be spoken before
continuing). The default is False.
|
SpeakXML
|
Optional
|
Variant
|
True will
cause the Text to be interpreted as XML. False will
cause the Text to not be interpreted as XML, so any XML tags will
be read and not interpreted. The default is False.
|
Purge
|
Optional
|
Variant
|
True will
cause current speech to be terminated and any buffered text to be purged
before Text is spoken. False will not cause the current
speech to be terminated and will not purge the buffered text before Text is
spoken. The default is False.
|
Using the Speech Object
Use
the Speech property of the Application object to return a Speech object.
Once
a Speech object is returned, you can
use the Speak method of Speech object to play back the contents
of a string. In the following example, Microsoft Excel plays back “Hello, How
are you”. This example assumes speech feature have been installed on the host
system.
Code:-
Set ObjExcel = CreateObject (“Excel.Application”)
ObjExcel.Speech.Speak
“Hello, How are you?”
Set ObjExcel=Nothing