Can you auto-trigger a sound file to play when a worksheet opens?

N

Nanotexan

I would like to have a sound wave play automatically when I open a particular
Excel worksheet. I have already added the sound wave into the worksheet, but
can't seem to find out how to have it self-trigger. Anyone have experience
with this. Working on Windows XP

Thanks
 
J

jeffP

Put these in a standard module:
Private Declare Function playSound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Sub Play_A_Wav()
WAVFile = ThisWorkbook.Path & "\Your.wav"
Call playSound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

In the worksheet you want it to play when you open put:
Private Sub Worksheet_Activate()
Call Play_A_Wav
End Sub


HTH
[email protected]
 
Top