ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Can you auto-trigger a sound file to play when a worksheet opens? (https://www.excelbanter.com/excel-worksheet-functions/63198-can-you-auto-trigger-sound-file-play-when-worksheet-opens.html)

Nanotexan

Can you auto-trigger a sound file to play when a worksheet opens?
 
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

jeffP

Can you auto-trigger a sound file to play when a worksheet opens?
 
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


"Nanotexan" wrote:

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



All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com