Results 1 to 2 of 2

Thread: Looping through cells and adding sound

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Looping through cells and adding sound

    Hi, I'm trying to add a .wav sound to all cells in a column if it equals "! ALERT !", the sound will play when we manually data to some cells in a column. I have created a macro and added the following code: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 = ThisWorkbook.Path & "\Windows Exclamation.wav" Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)End SubPrivate Sub Worksheet_Change(ByVal Target As Range) Threshold = "! ALERT !" If Range("AZ4").Value = Threshold Then PlayWAVEnd SubThis works for the first cell in the column and I'm assuming I'll need to add a loop within it to apply the same to the rest of the column cells. I would also like to reference .wav files in other files but using c:\BERT\BEAM-ME-UP-SCOTTY doesn't work? How do I do this and is it something to do with the FILEPATH? This is my first macro and I would appreciate help in achieving this, please help.Many thanksJ
    Last edited by Help for Heroes; 2013-04-07 at 01:06 PM. Reason: Tags

Posting Permissions

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