Play Sound

Embed Size (px)

DESCRIPTION

code vba

Citation preview

PlaySound() functionTo 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.)32-bit versions (Access 95 onwards): 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 Function16-bit versions (Access 1 or 2): 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