Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Darla Morrison   on Nov 29 In MS Office Category.

  
Question Answered By: Madeeha Malik   on Nov 29

Not all systems support sound. Determine whether your system supports
sound or not with:

If Not Application.CanPlaySOunds then
MsgBox "Sorry, no sound  on this sytem"
Exit Sub
End if

If you don't get the message above you can continue:

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

Private Declare Function mciExecute Lib "winmm.dll" _
(ByVal lpstrCommand As String) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Dim SoundFile As Variant


The following command will play the .wav file, let's say it's called
tic.wav:

Call PlaySound("C:\tic.wav", 0&, SND_ASYNC Or SND_FILENAME)


The .wav file is played asynchronously which means that code execution
continues while the sound is playing.

End of plagiarism.

Share: