Class Speech (Excel VBA)
Contains methods and properties that pertain to speech.
Returns or sets the order in which the cells will be spoken. The value of the Direction property is an XlSpeakDirection constant.Possible Values are xlSpeakByColumns - Reads down a column, then moves to the next column, xlSpeakByRows - Reads across a row, then moves to the next row.
Sub CheckSpeechDirection() ' Notify user of speech direction. If Application.Speech.Direction = xlSpeakByColumns Then MsgBox "The speech direction is set to speak by columns." Else MsgBox "The speech direction is set to speak by rows." End If End Sub
Microsoft Excel plays back the text string that is passed as an argument.
Sub UseSpeech() Application.Speech.Speak "Hello" End Sub
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.
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.
Sub SpeechCheck() ' Determine mode setting and notify user. If Application.Speech.SpeakCellOnEnter = True Then MsgBox "The Speak On Enter mode is turned on." & _ "The active cell will be spoken when the Enter " & _ "key is pressed or it is done being edited." Else MsgBox "The Speaker On Enter mode is turned off." End If End Sub