Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA to trigger a sound effect

Am looking for a simple way to make Excel play a midi or wav file, so that
spreadsheet can make reasuring sounds, or helpful comments at appropriate
stages. Has anyone tried this?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA to trigger a sound effect

You can get some information at John Walkenbach's site:

http://j-walk.com/ss/excel/tips/tip87.htm
Playing a Sound Based on a Cell's Value

http://j-walk.com/ss/excel/tips/tip59.htm
Playing Sound From Excel


If you need information on events in excel, see Chip Pearson's page on this

http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy

"Hotbird" wrote in message
...
Am looking for a simple way to make Excel play a midi or wav file, so that
spreadsheet can make reasuring sounds, or helpful comments at appropriate
stages. Has anyone tried this?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA to trigger a sound effect

Many thanks Tom. Once again you come to my rescue. This is where your
suggestion led:

Option Explicit

'Windows API function declaration

Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

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

On Error GoTo ErrHandler
If Evaluate(Cell.Value & Condition) Then
WAVFile = ThisWorkbook.Path & "\sound1.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm1 = True
Exit Function
End If
ErrHandler:
Alarm1 = False

End Function
Function Alarm2(Cell, Condition)

On Error GoTo ErrHandler
If Evaluate(Cell.Value & Condition) Then
WAVFile = ThisWorkbook.Path & "\sound2.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm2 = True
Exit Function
End If
ErrHandler:
Alarm2 = False

End Function

Regards,
Tom Ogilvy

"Hotbird" wrote in message
...
Am looking for a simple way to make Excel play a midi or wav file, so

that
spreadsheet can make reasuring sounds, or helpful comments at

appropriate
stages. Has anyone tried this?



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
How to make a cell trigger a Sound in Excel justice Excel Worksheet Functions 3 July 11th 06 10:22 AM
Can you auto-trigger a sound file to play when a worksheet opens? Nanotexan Excel Worksheet Functions 1 February 5th 06 05:16 PM
macro trigger Leslieac Excel Discussion (Misc queries) 3 February 2nd 06 09:08 PM
trigger help climax Excel Worksheet Functions 1 February 2nd 06 04:39 PM
trigger problem climax Excel Discussion (Misc queries) 1 February 2nd 06 12:39 AM


All times are GMT +1. The time now is 01:47 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"