ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   WAV FILE (https://www.excelbanter.com/excel-programming/337038-wav-file.html)

bassfisher

WAV FILE
 
how can i get a wav file to play in excel xp as an alarm when a value in a
particular cell has been exceeded?


Jim Thomlinson[_4_]

WAV FILE
 
Give this a try... If the value in Cell A1 on the sheet that this code is
placed in is change to anything greater than 100 then the wave file plays...

Option Explicit

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


Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And Target.Value 100 Then _
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

--
HTH...

Jim Thomlinson


"bassfisher" wrote:

how can i get a wav file to play in excel xp as an alarm when a value in a
particular cell has been exceeded?


Ron de Bruin

WAV FILE
 
Hi

See John's example
http://www.j-walk.com/ss/excel/tips/tip87.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl


"bassfisher" wrote in message ...
how can i get a wav file to play in excel xp as an alarm when a value in a
particular cell has been exceeded?




bassfisher

WAV FILE
 


"Jim Thomlinson" wrote:

Give this a try... If the value in Cell A1 on the sheet that this code is
placed in is change to anything greater than 100 then the wave file plays...

Option Explicit

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


Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And Target.Value 100 Then _
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

--
HTH...

Jim Thomlinson


"bassfisher" wrote:

how can i get a wav file to play in excel xp as an alarm when a value in a
particular cell has been exceeded?

Jim,

i placed the code in the worksheet, changed the cell values, but it wont'
play a file!
i am new to programming in excel.
any help would be appreciated.

thanx,
bassfisher


All times are GMT +1. The time now is 12:23 PM.

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