Introduction
Excel VBA’s text-to-speech feature can do more than just read the values in cells; it can speak any text string you define within your program.
By utilizing this feature, you can provide more active feedback to users. For example, you can announce “Input Instructions” when a specific sheet is opened or notify the user via voice when a macro has completed its processing.
In this article, I will introduce a simple and practical macro that uses the Application.Speech.Speak method to make Excel read specific text aloud.
Note: To use this feature, your PC needs a text-to-speech engine installed (standard on most Windows OS) and speakers or headphones connected.
VBA Sample Code to Read Text Aloud
This macro is written in the Worksheet_Activate event procedure. The moment the user selects (activates) this sheet, it plays a voice announcement and moves the cursor to a specific cell.
Sheet Module Code (Right-click the sheet tab -> Select “View Code” and paste this into the window)
' Event executed when the worksheet becomes active
Private Sub Worksheet_Activate()
Dim alertMessage As String
' Prepare the message you want read aloud
alertMessage = "Starting work. First, please enter the person in charge in cell B2."
' Read the message using the Application.Speech.Speak method
Application.Speech.Speak Text:=alertMessage
' Select cell B2
Me.Range("B2").Activate
End Sub
Explanation of the Code
Private Sub Worksheet_Activate()
This is a special event procedure. It executes automatically the moment the worksheet containing this code is selected and becomes active.
Application.Speech.Speak Text:=alertMessage
This is the core part that reads the string.
Application.Speech: The object that controls Excel’s speech functions..Speak: The method that converts text to speech and plays it.Text:=alertMessage: The argument of the Speak method where you specify the text string you want read aloud.
Reading Asynchronously (Background Processing)
The .Speak method has an argument called SpeakAsync.
If you set it to True like this: Application.Speech.Speak Text:=alertMessage, SpeakAsync:=True
The audio playback will happen in the background, and VBA will proceed to the next line of code (Me.Range("B2").Activate) without waiting for the speech to finish. This is useful when you want to prompt the next action immediately while the announcement is playing. The default value is False (waits for the speech to finish).
How to Stop Reading
If you want to interrupt the process while the text is being read, press the Esc key on your keyboard.
Summary
In this article, I explained how to make Excel read arbitrary messages using the Application.Speech.Speak method in VBA.
- You can easily make Excel speak by using
Application.Speech.Speak "Message". - By combining this with events like
Worksheet_Activate, you can automatically play voice guidance at specific times.
By adding auditory feedback to standard message boxes and validation rules, you can create tools that are more user-friendly and easier to understand.
