Provided by Allen Browne. Last updated: April 2010.
To play a sound in any event, just set an event such as a form's OnOpen to:
=PlaySound("C:\WINDOWS\CHIMES.WAV")
Paste the declaration and function into a module, and save.
Use the 16-bit version for Access 1 and 2.
Note that these calls will not work with the 64-bit version of Office (as distinct from the 64-bit versions of Windows.)
Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _
(ByVal filename As String, ByVal snd_async As Long) As Long
Function PlaySound(sWavFile As String)
' Purpose: Plays a sound.
' Argument: the full path and file name.
If apisndPlaySound(sWavFile, 1) = 0 Then
MsgBox "The Sound Did Not Play!"
End If
End Function
Declare Function sndplaysound% Lib "mmsystem" (ByVal filename$, ByVal snd_async%) Function PlaySound (msound) Dim XX% XX% = sndplaysound(msound, 1) If XX% = 0 Then MsgBox "The Sound Did Not Play!" End Function
Home | Index of tips | Top |