Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
How to get Excel to speak to you - reading out the contents of cells Part three of a three-part series of blogs |
---|
Deep within its bowels Excel contains a feature allowing it to read out the contents of cells (you can also get your VBA macros to talk to users). This blog goes to those deep places hidden within Excel!
|
The previous part of this blog showed how you can get Excel to read things out to you, but you can also perform the same trick in VBA.
Newcomers to VBA might like to read the first bit of our Excel VBA tutorial at this point, before proceeding further, or even consider booking one of our training courses in VBA.
Here's a basic subroutine to speak to you:
Sub SaySomethingSimple()
'say something!
Application.Speech.Speak ("Wise Owl")
End Sub
The Speak method has 3 arguments, but only the first one is of any interest, as this Microsoft page demonstrates.
If you want to get Excel to do this, you could run this macro!
Sub ReadPrimes()
Dim ThisNumber As Integer
Dim i As Integer
Dim IfPrime As Boolean
'hideously inefficient algorithm!
For ThisNumber = 2 To 100
IfPrime = True
For i = 2 To Int(Math.Sqr(ThisNumber))
If ThisNumber Mod i = 0 Then
IfPrime = False
Exit For
End If
Next i
If IfPrime Then Application.Speech.Speak CStr(ThisNumber)
Next ThisNumber
End Sub
Probably the best use of Excel speech is to read out the contents of cells. This nifty macro would read out the contents of all of the values in column A, colouring each in as it went:
Sub ReadCellValues()
Dim DataRange As Range
Dim DataCell As Range
'get reference to range of data
Range("A1").Select
Set DataRange = Range( _
ActiveCell.Offset(1, 0), _
ActiveCell.End(xlDown))
'loop over cells, reading each
'and then colouring in
For Each DataCell In DataRange
DataCell.Interior.Color = RGB(250, 220, 240)
Application.Speech.Speak ( _
Replace(DataCell.Address, "$", "") & _
" = " & _
DataCell.Value)
Next DataCell
End Sub
Here's the macro in action (the data is actually my scores at an app called Scramble, if you must know):
The macro has read out so far:
As you can see from the above three examples, the world of speech is now your oyster!
Parts of this blog |
---|
|
Some other pages relevant to the above blogs include:
From: | mg6116 |
When: | 01 Jul 20 at 15:19 |
Is there any possibility in Excel to make it speak in other languages (Dutch for exeaple) using VBA ("application.speech"). I don't seem to be able to select a Dutch voice with "speech.Getvoices.item(x)", although I have a Dutch voice in Windows 10.
From: | Andy B |
When: | 01 Jul 20 at 15:47 |
I honestly don't know! Anyone else ever seen this?
From: | mg6116 |
When: | 03 Jul 20 at 11:59 |
I found the answer myself. This site is great. And it works. I have a Dutch voice now in Excel. Should work for all other languages you can download from Microsoft.
From: | Andy B |
When: | 03 Jul 20 at 12:06 |
That's so cool! Although slightly scary too, as it involves editing the registry. I haven't tried it - I think I'll stick with Microsoft English ...
From: | edgarfreitas |
When: | 26 Sep 16 at 11:33 |
I just read this article about "Getting Excel vba speak to you". My question is if you could help me setting up my excel sheet to speak a few selected cells when I press the "calculate" button. Is this possible to do with excel? I have about 8 cells that gives me some calculation results that I would like to be read when I press the calculate button.
From: | Andy B |
When: | 26 Sep 16 at 16:04 |
I've written a separate blog explaining how to do this.
From: | edgarfreitas |
When: | 27 Sep 16 at 11:09 |
Thank you so much for replying to my message on your blog. It worked perfectly! Now, I just click the calculate button and then excel speaks the cells I've chosen.
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.