Class Speech (Excel VBA)

Contains methods and properties that pertain to speech. To use a Speech class variable it first needs to be instantiated, for example


Dim spc as Speech
Set spc = Application.Speech

Direction

Returns or sets the order in which the cells will be spoken. The value of the Direction property is an XlSpeakDirection constant. Possible return values are xlSpeakByColumns - Reads down a column, then moves to the next column, xlSpeakByRows - Reads across a row, then moves to the next row.


Application.Speech.Direction = xlSpeakByColumns

Speak

Microsoft Excel plays back the text string that is passed as an argument.

Speak (Text, SpeakAsync, SpeakXML, Purge)


Dim strText As String: strText = "Hello" 
Application.Speech.Speak Text:=strText

Arguments

The following argument is required

Text (String) - The text to be spoken.

Optional arguments

The following arguments are optional

SpeakAsync - True causes the text to be spoken asynchronously (the method will not wait for the text to be spoken). False causes the text to be spoken synchronously (the method waits for the text to be spoken before continuing). The default is False

SpeakXML - True causes the text to be interpreted as XML. False causes the text to not be interpreted as XML, so any XML tags are read and not interpreted. The default is False

Purge (Boolean) - True causes current speech to be terminated and any buffered text to be purged before text is spoken. False does not cause the current speech to be terminated and does not purge the buffered text before text is spoken. The default is False.

SpeakCellOnEnter

Microsoft Excel supports a mode where the active cell is spoken when the Enter key is pressed or when the active cell is finished being edited. Setting the SpeakCellOnEnter property to True turns this mode on. False turns this mode off.


Application.Speech.SpeakCellOnEnter = True