Name

speech.Speak(Text, [SpeakAsync], [SpeakXML], [Purge])

Synopsis

Reads text out loud.

Argument

Settings

Text

The text to read out loud.

SpeakAsync

True executes the next statement without waiting for the reading to complete; False pauses code until Text has been completely read. Default is False.

SpeakXML

True interprets Text as XML or HTML, skipping tags; False reads all text. Default is False.

Purge

True stops the current text being read and starts reading the new text immediately; False waits for current text to complete before reading new text. Default is False.

The following code reads a short poem:

Sub ReadPoem(  )
    Dim spch As Speech, poem As String
    Set spch = Application.Speech
    poem = "Some men lead lives of quiet desperation. " & _
      "Our Joey lays in silent anticipation, " & _
      "of morsels dropped from Sophie's eating station."
    spch.Speak poem
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.