Speech Object

Office XP comes with a speech recognition feature that makes it possible to read text on demand. The text can be read automatically on data entry by clicking the Speak on Enter button on the Text to Speech toolbar (choose Tools | Speech). You can also control the speech feature via the Speech object from a VBA procedure. This object has the Speak method that causes the text to be spoken by Excel. To cause the active cell to be spoken on entry or when it is finished being edited, set the SpeakCellOnEnter property of the Speech object to True:

Application.Speech.SpeakCellOnEnter = True Notice that the Speech object is accessed via the Application object.

Sub ReadNamesWithHighScores() Dim v As Integer

Sub ReadNamesWithHighScores() Dim v As Integer v = InputBox("Enter the minimum expected score:", "Approved Minimum")

For Each cell In ActiveSheet.Columns("B").Cells

If IsNumeric(cell.Value) And cell.Value >= v Then

Application.Speech.Speak "Congratulations" &_

cell.0ffset(0, -1).Text Application.Speech.Speak "your score is " & cell.Text End If

Next End Sub

0 0

Post a comment