computing
  • 0

Solved Can I make excel play a sound

  • 0

Can I make excel play a sound based on the output of a formula. I have been through all of the excel commands and I cant find an Insert Sound Funtion

Many Thanks

Share

1 Answer

  1. Ref Sound through excel

    If On Database appears in Col X then it plays a sound

    =COUNTIF($X$2:$X$2023,”On Database”)

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range(“X1”).Value = “1” Then
    PlayWav
    End If
    End Sub

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

    Sub PlayWav()
    Dim WAVFile As String
    Const SND_ASYNC = &H1
    Const SND_FILENAME = &H20000
    On Error GoTo ErrHandler
    WAVFile = “C:BackupSound.wav”
    Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
    Exit Sub
    ErrHandler:
    End Sub

    message edited by emory

    • 0