Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Audible Alert in Excel macro (other than "Beep") 2

Status
Not open for further replies.

AliJay

Technical User
Sep 19, 2004
27
SG
Hi guys,

Is there a way that an audible alert in Excel can be anything other than the "beep" function in a macro?

Is there a way of opening another audio file or maybe assigning a "Beep2" to another audio file and using that as well. I have two other events to which I have asigned the "Beep" function and I am looking for a less confusing way to add additional audio beeps from a monitoring macro.

Thanks in advance guys, all help advice greatfully received

AJ
 
You can use API to change the Audio of Beep to different tone by changing the frequency and duration.
Code:
Private Declare Function APIBeep Lib "kernel32" Alias _
  "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) _
    As Long

Private Sub Command1_Click()
Dim frequency As Long, duration As Long
    frequency = 1100
    duration = 100
    APIBeep frequency, duration
End Sub

Or if you are using XP then try without API declaration

Code:
Private Sub Command0_Click()
Dim vo As Object
Set vo = CreateObject("SAPI.SpVoice")
vo.Speak "my boss is the best"
End Sub
The second is from PHV's post somewhere in TT. I can't find the thread which started many months before.

________________________________________________________________________
Zameer Abdulla
Visit Me
No two children are alike - particularly if one is yours and the other isn't.
 
Or you could look into the sndPlaySound API (see this sample PlaySound()) or look up the PlaySound API - then Bep, Beep...

Roy-Vidar
 
Thank you Zameer and Roy. Both posts very helpful.

All the best

AJ
 
I tried to use the macros as given by the posts but i think that they are for Access and not Excel as they don't seem to work.

Basically I need to run a .wav file from a macro in Excel - is there a function that can do this?

Thanks again

AJ
 
That looks more like it ... Thanks Zameer.

My stop-gap solution was to put in a hyperlink in my worksheet to a .wav file on the drive and when a level was reached to activate the hyperlink. Not very elegant!!

All the best my friend

AJ


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top