Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default Playing Embedded Sound

Hi All,

I'm trying to play an embedded sound file in excel and want to know if there
is a way to do it without it opening another app (e.g. Windows Media Player).
I want to have a sound attached to a form that appears when you open the
workbook.

I am currently using a Wav file in Excel 2007 but can use other file types
if they'll work better.

Thanks
Chris
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Playing Embedded Sound

Chris,

Just a thought. Here is what I have that plays a wav file "without a
player" when a cell condition is met. To use this code as-is, you might try
placing a condition in a cell. Put a 1 in A1, then in A2 use formula
=Alarm(A1,"=1"). Not sure if it will re-evaluate every time, but you can
give it a try.

Mike

From John Walkenbach "Excel 2000 Power Programming"

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


Function Alarm(Cell, Condition)
Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
On Error GoTo errHandler
If Evaluate(Cell.Value & Condition) Then
WAVFile = ThisWorkbook.Path & "\secalert.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = True
Exit Function
End If
errHandler:
Alarm = False
End Function


"Chris" wrote:

Hi All,

I'm trying to play an embedded sound file in excel and want to know if there
is a way to do it without it opening another app (e.g. Windows Media Player).
I want to have a sound attached to a form that appears when you open the
workbook.

I am currently using a Wav file in Excel 2007 but can use other file types
if they'll work better.

Thanks
Chris

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
playing a sound in a macro Kelly 1st Excel Programming 5 November 28th 05 12:30 PM
Playing sound in VBA Pete[_22_] Excel Programming 3 October 10th 05 02:01 PM
Problem with playing sound code EMoe[_39_] Excel Programming 3 July 6th 05 01:30 AM
playing sound??? tess457[_6_] Excel Programming 2 October 20th 04 11:50 AM
Playing a sound base on cell value Mike[_58_] Excel Programming 4 November 30th 03 03:53 AM


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