+ Reply to Thread
Results 1 to 2 of 2

play a WAV sound in a code... how to do it?

  1. #1
    Registered User
    Join Date
    03-11-2005
    Posts
    87

    play a WAV sound in a code... how to do it?

    Hi all,

    I have a Worksheet_Calculate code that each time an event is triggered needs to play a WAV sound on the harddisk... how can i do it?

    Many thanks

    BC

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello BC,

    Place this code in a VBA module. To play the wave file: PlaySound ("file Path and Name")

    Macro Code:

    'dwFlags Constants
    Const SND_SYNC As Long = 0
    Const SND_ASYNC As Long = 1
    Const SND_FILENAME As Long = &H20000
    Const SND_RESOURCE As Long = &H40004

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

    Public Sub PlaySound(ByVal File_Name As String)

    Dim RetVal
    RetVal = PlaySnd (File_Name, 0&, SND_ASYNC Or SND_FILENAME)

    End Sub


    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1