ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Play Sound File Once when cell value condition id met (https://www.excelbanter.com/excel-discussion-misc-queries/156623-play-sound-file-once-when-cell-value-condition-id-met.html)

John 1

Play Sound File Once when cell value condition id met
 
Could someone please explain how I get a sound file to run once the value in
a cell exceeds a specific value.

The cell value contains realtime data and, therefore, I would only want it
to play once (or twice) and then wait until I reset thee trigger value

Thanks in advance,
John

Jim Thomlinson

Play Sound File Once when cell value condition id met
 
This requires macros... I assume you are OK with macros??? How is you comfort
level with macros written from scratch...

Next you need to define real time data... where is the data coming from and
does it trigger the change event in XL or is there some kind of update
routine that can be captured.
--
HTH...

Jim Thomlinson


"John 1" wrote:

Could someone please explain how I get a sound file to run once the value in
a cell exceeds a specific value.

The cell value contains realtime data and, therefore, I would only want it
to play once (or twice) and then wait until I reset thee trigger value

Thanks in advance,
John


John 1[_2_]

Play Sound File Once when cell value condition id met
 
I am only OK with basic macros.

I have the code from a previous thread in 2006 but once triggered the sound
continues to loop and will not stop until the value goes below the trigger
level.
...............
Option Explicit
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private Sub Worksheet_Calculate()
If Me.Range("b2").Value 200 Then
sndPlaySound32 "G:\DATA\scans\New Position.wav", 0
End If
End Sub

.................................
Just need to be able to stop after played once or twice????????????

Thanks,
John


"Jim Thomlinson" wrote:

This requires macros... I assume you are OK with macros??? How is you comfort
level with macros written from scratch...

Next you need to define real time data... where is the data coming from and
does it trigger the change event in XL or is there some kind of update
routine that can be captured.
--
HTH...

Jim Thomlinson


"John 1" wrote:

Could someone please explain how I get a sound file to run once the value in
a cell exceeds a specific value.

The cell value contains realtime data and, therefore, I would only want it
to play once (or twice) and then wait until I reset thee trigger value

Thanks in advance,
John


Jim Thomlinson

Play Sound File Once when cell value condition id met
 
Give this a whirl...

Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private m_lngReset As Long

Private Sub Worksheet_Calculate()
If Me.Range("b2").Value 200 And m_lngReset < 2 Then 'you can change the 2
sndPlaySound32 "G:\DATA\scans\New Position.wav", 0
m_lngReset = m_lngReset + 1
End If
End Sub

'Run this to reset the sound
Public Sub ResetSound()
m_lngReset = 0
End Sub
--
HTH...

Jim Thomlinson


"John 1" wrote:

I am only OK with basic macros.

I have the code from a previous thread in 2006 but once triggered the sound
continues to loop and will not stop until the value goes below the trigger
level.
..............
Option Explicit
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private Sub Worksheet_Calculate()
If Me.Range("b2").Value 200 Then
sndPlaySound32 "G:\DATA\scans\New Position.wav", 0
End If
End Sub

................................
Just need to be able to stop after played once or twice????????????

Thanks,
John


"Jim Thomlinson" wrote:

This requires macros... I assume you are OK with macros??? How is you comfort
level with macros written from scratch...

Next you need to define real time data... where is the data coming from and
does it trigger the change event in XL or is there some kind of update
routine that can be captured.
--
HTH...

Jim Thomlinson


"John 1" wrote:

Could someone please explain how I get a sound file to run once the value in
a cell exceeds a specific value.

The cell value contains realtime data and, therefore, I would only want it
to play once (or twice) and then wait until I reset thee trigger value

Thanks in advance,
John


John 1[_2_]

Play Sound File Once when cell value condition id met
 
Thanks Jim, appreciate that........ will give it a go on Monday but looks
good to me.

As a point of interest is there a place where I can find the necessary
variables (eg m_lngReset ) and the functions to call?

Is there a way to run the ResetSound routine directly from the worksheet?

Cheers,
John



"Jim Thomlinson" wrote:

Give this a whirl...

Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private m_lngReset As Long

Private Sub Worksheet_Calculate()
If Me.Range("b2").Value 200 And m_lngReset < 2 Then 'you can change the 2
sndPlaySound32 "G:\DATA\scans\New Position.wav", 0
m_lngReset = m_lngReset + 1
End If
End Sub

'Run this to reset the sound
Public Sub ResetSound()
m_lngReset = 0
End Sub
--
HTH...

Jim Thomlinson


"John 1" wrote:

I am only OK with basic macros.

I have the code from a previous thread in 2006 but once triggered the sound
continues to loop and will not stop until the value goes below the trigger
level.
..............
Option Explicit
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private Sub Worksheet_Calculate()
If Me.Range("b2").Value 200 Then
sndPlaySound32 "G:\DATA\scans\New Position.wav", 0
End If
End Sub

................................
Just need to be able to stop after played once or twice????????????

Thanks,
John


"Jim Thomlinson" wrote:

This requires macros... I assume you are OK with macros??? How is you comfort
level with macros written from scratch...

Next you need to define real time data... where is the data coming from and
does it trigger the change event in XL or is there some kind of update
routine that can be captured.
--
HTH...

Jim Thomlinson


"John 1" wrote:

Could someone please explain how I get a sound file to run once the value in
a cell exceeds a specific value.

The cell value contains realtime data and, therefore, I would only want it
to play once (or twice) and then wait until I reset thee trigger value

Thanks in advance,
John



All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com