playing sound???

  • Thread starter Thread starter tess457
  • Start date Start date
T

tess457

is there anyway of playing a sound once a user opens my excel file??
Thanks!
 
Hi Tess457,

Put this code in the workbook open event...

Private Sub Workbook_Open()
PlayWAV
End Sub

This code will play any wav you need as long as the wav is in the
same folder/directory as the workbook... just put it in a module

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

Sub PlayWAV()
WAVFile = "yoursound.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

and it shouls play your sound file when you open the workbook..

hope this helps...

ste
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top