hi there,
I have 3 cells containing data from the outside world for 3 machines, when the machines are running the cell value in lets say a1 would equal 1, b1 would equal 1 and c1 would equal 1. When any machine stops its value changes to 0. I want to play a voice sound for each machine being off. (if a1=0 then say "machine 1 off" etc). My problem is I only want the voice file to play once. When a second machine stops I don't get what I require.
using the playsound code below and calling the sound from the worksheet_calculate
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 PlayWAVmachine1()
'play shuttle alarm sound a1 value=0
WAVFile = "machine1.wav"
WAVFile = ThisWorkbook.Path & "" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub
Sub PlayWAVmachine2()
'play shuttle alarm sound b1 value =0
WAVFile = "machine2.wav"
WAVFile = ThisWorkbook.Path & "" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub
Sub PlayWAVmachine3()
'play shuttle alarm sound c1 value=0
WAVFile = "machine3.wav"
WAVFile = ThisWorkbook.Path & "" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub
cheers
Stuart
I have 3 cells containing data from the outside world for 3 machines, when the machines are running the cell value in lets say a1 would equal 1, b1 would equal 1 and c1 would equal 1. When any machine stops its value changes to 0. I want to play a voice sound for each machine being off. (if a1=0 then say "machine 1 off" etc). My problem is I only want the voice file to play once. When a second machine stops I don't get what I require.
using the playsound code below and calling the sound from the worksheet_calculate
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 PlayWAVmachine1()
'play shuttle alarm sound a1 value=0
WAVFile = "machine1.wav"
WAVFile = ThisWorkbook.Path & "" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub
Sub PlayWAVmachine2()
'play shuttle alarm sound b1 value =0
WAVFile = "machine2.wav"
WAVFile = ThisWorkbook.Path & "" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub
Sub PlayWAVmachine3()
'play shuttle alarm sound c1 value=0
WAVFile = "machine3.wav"
WAVFile = ThisWorkbook.Path & "" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub
cheers
Stuart