Need help playing embedded wav/mp3 when condition is met

1nk3d

Board Regular
Joined
May 31, 2016
Messages
51
I need help with this spreadsheet. We cannot load the sound files on computers, so the files need to be embedded. They can be a wav or an mp3. The spreadshet is used to track projected hours for each store. Ideally we would like a cash register sound (green.wav) to play when the value is greater than 0, however the number is always greater than 0 as it counts down the hours, so unless there is a way to hide the value until all cells are completed?

What would probably be easier is to play a whammy sound of sort when the value is negative. I have it working, however it only works when my thumb drive is in the computer as th sound file is located there. So I need a file to point to the location of it on an embedded shet, maybe we can hide it?

I can't run any sort of script to temporarily put the file somewhere, as these are government computers....

Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD]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


Private Sub Worksheet_Calculate()
Const FName As String = "bad.wav"
If Range("I2").Value > 22.2 Then
Call PlaySound(FName, 0&, SND_ASYNC Or SND_FILENAME)
End If
End Sub
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Can't figure out how to edit, but in the above code, it lists 22.2 as the value, it should be less than 0. Sorry
 
Upvote 0
Perhaps we can use, is it vytes? to move file temporarily to desktop, however, each user has a different log on id... Also would it be possible just to hyperlink the file?
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top