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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional Formating and a Sound Wave

Status
Not open for further replies.

jamason07

IS-IT--Management
Aug 28, 2003
46
US
I would like an audio notification when a condition in met in a form. I've set the conditional formating to change colors. Anyone have any ideas of how to attach a sound wave file to activate when the condition is met? Thanks much!

Jeffrey
 
this is the easy way. just edit the path and sound file you want to play.

Private Sub Command4_Click()
Call PlaySound("C:\Windows\Media\chord.wav")
End Sub
 
Hi drctx,

You've forgotten to tell jamason07 that the API and Constants need to be pasted into the Declarations Section of a Module:
Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" _
(ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Public Const SND_SYNC = &H0
Public Const SND_ASYNC = &H1
Public Const SND_NODEFAULT = &H2
Public Const SND_LOOP = &H8
Public Const SND_NOSTOP = &H10
Public Const SND_PURGE = &H40

Then to call PlaySound:
Dim strWav As String
strWav = "C:\Windows\Media\chord.wav" ' change this to your .wav file
Call PlaySound(strWav, 0, SND_ASYNC Or SND_NODEFAULT)

Easily done, I do it all the time.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top