Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How do I insert music into a formula for when a result occurs

I have a DDE link to an Excel spreadsheet, and would like to be notified by
an alert (preferably music) when a specific formula result occurs.

Any solutions greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default How do I insert music into a formula for when a result occurs

Hi,

have a look here
http://www.j-walk.com/ss/excel/tips/tip59.htm
Mike

"Bobh" wrote:

I have a DDE link to an Excel spreadsheet, and would like to be notified by
an alert (preferably music) when a specific formula result occurs.

Any solutions greatly appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default How do I insert music into a formula for when a result occurs

The link that Mike H posted has good solution - I just borrowed some of that
to provide audio ability in a file to one of my clients.

In your case you could use the Worksheet_Calculate() event handler for the
sheet with the formula you're interested in to examine the result of the
formula and if it's what you're looking for, then play the audio clip. Code
would look similar to this (it includes the code from John Walkenbach's site
page):

Option Explicit
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()
Dim WAVFile As String
WAVFile = "dogbark.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

Private Sub Worksheet_Calculate()
Const cellAddress = "$C$1" ' change
Const notifyValue = 7 ' value to alert on

If Range(cellAddress) = notifyValue Then
PlayWAV ' audio alert
End If
End Sub

That would all go into the sheet's code module - to get it there,
right-click on the sheet's name tab and choose [View Code] and cut and paste
the code into it and change the two const values cellAddress and notifyValue
as required.


"Bobh" wrote:

I have a DDE link to an Excel spreadsheet, and would like to be notified by
an alert (preferably music) when a specific formula result occurs.

Any solutions greatly appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default How do I insert music into a formula for when a result occurs

Better code for the Worksheet_Calculate() event. This will keep the audio
from playing every time the sheet is recalculated and the test value is at
the point you're interested in. Instead it will play the first time it
changes to the test value and then keep quiet unless the value changes to
something else and then back to the test value later.

Private Sub Worksheet_Calculate()
Const cellAddress = "$C$1" ' change
Const notifyValue = 7 ' value to alert on
Static AlreadyPlayed As Boolean

If Range(cellAddress) = notifyValue And _
Not AlreadyPlayed Then
PlayWAV
AlreadyPlayed = True
Else
AlreadyPlayed = False
End If
End Sub


"JLatham" wrote:

The link that Mike H posted has good solution - I just borrowed some of that
to provide audio ability in a file to one of my clients.

In your case you could use the Worksheet_Calculate() event handler for the
sheet with the formula you're interested in to examine the result of the
formula and if it's what you're looking for, then play the audio clip. Code
would look similar to this (it includes the code from John Walkenbach's site
page):

Option Explicit
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()
Dim WAVFile As String
WAVFile = "dogbark.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

Private Sub Worksheet_Calculate()
Const cellAddress = "$C$1" ' change
Const notifyValue = 7 ' value to alert on

If Range(cellAddress) = notifyValue Then
PlayWAV ' audio alert
End If
End Sub

That would all go into the sheet's code module - to get it there,
right-click on the sheet's name tab and choose [View Code] and cut and paste
the code into it and change the two const values cellAddress and notifyValue
as required.


"Bobh" wrote:

I have a DDE link to an Excel spreadsheet, and would like to be notified by
an alert (preferably music) when a specific formula result occurs.

Any solutions greatly appreciated.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advanced formula - Return result & Show Cell Reference of result Irv Excel Worksheet Functions 7 May 6th 06 03:36 AM
Formula to give 5%rise in a figure if it occurs b/wn 2 dates lwhat Excel Worksheet Functions 1 October 28th 05 11:21 AM
How do I have a formula check if a value occurs within a range? afgncaap Excel Worksheet Functions 3 June 1st 05 06:44 PM
how do I insert a row based on a function result chris Excel Worksheet Functions 3 May 25th 05 12:58 AM
formula to extract specific data if match occurs jerry Excel Worksheet Functions 2 February 24th 05 11:06 AM


All times are GMT +1. The time now is 09:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"