I recently published an article about getting information on the latest earthquake of magnitude 5 or greater.
Please read this article to see how the core model was constructed.
One problem with this model is that since Excel’s web functions are non-volatile, a formula containing those functions must be recalculated by reentering the formula. I decided that an easier way was needed to trigger an update. I also recently published an article which utilized the hyperlink rollover technique.
I figured that this might be a good way to trigger a recalculation. And, since I was going to use a VBA function to be called from the hyperlink formula, I thought that adding audio functionality would be useful as well. Here is the hyperlink rollover formula used (in cell D5, named Recalculate). Since a rollover is required, the technique is not truly realtime.
And, here is the VBA function called by “rolling over” (passing the cursor over) that cell.
Function EarthQuakeAlert(Optional Person As String = “Him”, _
Optional Rate As Long = 1, Optional Volume As Long = 80)
Static xlApp As New Excel.Application
Dim Voc As SpeechLib.SpVoice
Set Voc = New SpVoice
Dim sAddress As String
If Range(“d1”).Value = Range(“b3”).Value Then
MsgBox “No new earthquake > 5.0”
If Person = “Him” Then
Set .voice = .GetVoices.Item(0) ‘male
ElseIf Person = “Her” Then
Set .voice = .GetVoices.Item(1) ‘female
.Rate = Rate
.Volume = Volume
.Speak “New Earthquake Alert! ” & Range(“b5”).Value
Range(“d1”).Value = Range(“b3”).Value
EarthQuakeAlert = “Recalculate”
Set xlApp = Nothing
In order to use SpeechLib.SpVoice in the code, the correct reference (from Tools, References) must be added to the VBE as shown in the following figure.
In this figure is a picture of the earthquake model.
I hope that you find this useful. You can download the file here.