Play Sound

O

Owen

Hi

Does anybody know how to get a form to play a sound when the recipient opens
a specific form.

Thanks for any advice.

Owen
 
S

sparkle_guy

Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

then

If Application.CanPlaySounds Then
Call sndPlaySound32("pathname_of_wavfile_to_be_played", 0)

This works in a macro in excel it might work for you too
 
O

Owen

Sparkle

Thanks for the reply. I thought it may be simpler as I am not a great
programmer and the code you have sent doesn't make much sense.

Thanks

Owen
 
S

sparkle_guy

Just cut and paste the two bits into your macro or vbscript. The all you
have to do is put the correct path to the sound file. NB The sound file
needs to be a .wav file
 
O

Owen

Hi Sparkle

Followed your advice and just get compiler errors.

Only comments can appear after end sub, end function or end property.

Thnak for your help

Owen
 

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

Similar Threads

Sound not playing 2
Sound when receiveing new mail 0
Video Playback Windows 7 0
Odd 0
Embedded sound woes 0
Sound repeats unending until closing workbook 2
Sound Not Playing 0
Video across slides 0

Top