Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Hi all,
I don't know if I should be posting on Google groups or here, so forgive me if I'm not following protocol. Anyway, can someone show me how to add/play a sound to the following: Private Sub Worksheet_Calculate() If Range("I1").Value 0 Then Beep 'or msgbox 'or play sound 'or send email 'or whatever End If End Sub You'll notice that there is a "Beep" in the program but it doesn't work. Cheers Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Beep should work (bit naff, but works). Are you sure you don't have sound
muted? -- HTH RP (remove nothere from the email address if mailing direct) "Carlton Patterson" wrote in message ... Hi all, I don't know if I should be posting on Google groups or here, so forgive me if I'm not following protocol. Anyway, can someone show me how to add/play a sound to the following: Private Sub Worksheet_Calculate() If Range("I1").Value 0 Then Beep 'or msgbox 'or play sound 'or send email 'or whatever End If End Sub You'll notice that there is a "Beep" in the program but it doesn't work. Cheers Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Hi Bob,
I'm positive mate. Its a little strange because I'm sure it beeped the first time I executed it. Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Hi Carlton,
Try this then Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _ (ByVal lpszName As String, _ hModule As Long, _ ByVal dwFlags As Long) As Long Private Sub Workbook_Calculate() If Range("I1").Value 0 Then PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav" End If End Sub 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 If this doesn't work, check mute again <g -- HTH RP (remove nothere from the email address if mailing direct) "Carlton Patterson" wrote in message ... Hi Bob, I'm positive mate. Its a little strange because I'm sure it beeped the first time I executed it. Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Hi Bob,
I managed to get a Beep when I pasted this program into excel. So I don't understand why I the simple program I pasted earlier won't work, uhmmmmm.... Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column 2 Then Exit Sub 'A or B okay If Cells(Target.Row, 1) < Cells(Target.Row, 2) Then Beep End If End Sub Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
LOL.
There is no Workbook_Calculate event, it is Worksheet_Calculate! -- HTH RP (remove nothere from the email address if mailing direct) "Carlton Patterson" wrote in message ... Hi Bob, I managed to get a Beep when I pasted this program into excel. So I don't understand why I the simple program I pasted earlier won't work, uhmmmmm.... Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column 2 Then Exit Sub 'A or B okay If Cells(Target.Row, 1) < Cells(Target.Row, 2) Then Beep End If End Sub Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Hee hee,
I should've seen that. Cheers mate. Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Hello Bob,
while on the subject of sounds, is it possible to program excel to play a sound as a value increments? For example, lets say I have a cell with the current value of 1, I would like to hear a single beep. Then, if the value goes up to 2 I would like to hear another single beep and so on... Is that possible? Cheers mate. Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Hi Carlton,
easy enough Private Sub Worksheet_Calculate() Static prevValue If Range("I1").Value prevValue Then Beep prevValue = Range("I1").Value End If End Sub -- HTH RP (remove nothere from the email address if mailing direct) "Carlton Patterson" wrote in message ... Hello Bob, while on the subject of sounds, is it possible to program excel to play a sound as a value increments? For example, lets say I have a cell with the current value of 1, I would like to hear a single beep. Then, if the value goes up to 2 I would like to hear another single beep and so on... Is that possible? Cheers mate. Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Hi Bob,
Thats great mate. Cheers mate Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Paste this program in a new module
Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long Sub Beep1() Dim num As Single Dim num1 As Long Dim numLoops As Single num = 10 NumSeconds = 4 numLoops = (NumSeconds * num * 2) / 2 If numLoops < 1 Then numLoops = 1 End If num1 = 1000 / (num * 2) For i = 1 To numLoops 'DoEvents Beep 500, num1 'DoEvents Beep 10000, num1 'DoEvents Next End Sub ----------------------------------- Execute/run the Beep1 macro. While it is running see where the beep is coming from - From your sound card, or from your system unit itself? Playsound should come from your sound card, but I would expect beep to come from the built in speaker of your computer. -- Regards, Tom Ogilvy "Carlton Patterson" wrote in message ... Hi Bob, Thats great mate. Cheers mate Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
If a worksheet beeps, but no one is around to hear it, does it still make a
sound? "Carlton Patterson" wrote in message ... Hi all, I don't know if I should be posting on Google groups or here, so forgive me if I'm not following protocol. Anyway, can someone show me how to add/play a sound to the following: Private Sub Worksheet_Calculate() If Range("I1").Value 0 Then Beep 'or msgbox 'or play sound 'or send email 'or whatever End If End Sub You'll notice that there is a "Beep" in the program but it doesn't work. Cheers Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Schrodinger's spreadsheet? What sort of animal is that?
Bob "Steve Schroeder" wrote in message ... If a worksheet beeps, but no one is around to hear it, does it still make a sound? "Carlton Patterson" wrote in message ... Hi all, I don't know if I should be posting on Google groups or here, so forgive me if I'm not following protocol. Anyway, can someone show me how to add/play a sound to the following: Private Sub Worksheet_Calculate() If Range("I1").Value 0 Then Beep 'or msgbox 'or play sound 'or send email 'or whatever End If End Sub You'll notice that there is a "Beep" in the program but it doesn't work. Cheers Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Don't make me hurt ya now :-P
"Bob Phillips" wrote in message ... Schrodinger's spreadsheet? What sort of animal is that? Bob "Steve Schroeder" wrote in message ... If a worksheet beeps, but no one is around to hear it, does it still make a sound? "Carlton Patterson" wrote in message ... Hi all, I don't know if I should be posting on Google groups or here, so forgive me if I'm not following protocol. Anyway, can someone show me how to add/play a sound to the following: Private Sub Worksheet_Calculate() If Range("I1").Value 0 Then Beep 'or msgbox 'or play sound 'or send email 'or whatever End If End Sub You'll notice that there is a "Beep" in the program but it doesn't work. Cheers Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#15
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
I said Schrodinger's, not Schroeder's, Ernst not Steve ;-)
"Steve Schroeder" wrote in message ... Don't make me hurt ya now :-P "Bob Phillips" wrote in message ... Schrodinger's spreadsheet? What sort of animal is that? Bob "Steve Schroeder" wrote in message ... If a worksheet beeps, but no one is around to hear it, does it still make a sound? "Carlton Patterson" wrote in message ... Hi all, I don't know if I should be posting on Google groups or here, so forgive me if I'm not following protocol. Anyway, can someone show me how to add/play a sound to the following: Private Sub Worksheet_Calculate() If Range("I1").Value 0 Then Beep 'or msgbox 'or play sound 'or send email 'or whatever End If End Sub You'll notice that there is a "Beep" in the program but it doesn't work. Cheers Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#16
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Hi Tom,
Thanks for the program, however the following statement is highlighted in red followed by this error message: Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long Compile Error: Expected: list separator or ) Cheers Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#17
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
That should all be one line.
-- HTH RP (remove nothere from the email address if mailing direct) "Carlton Patterson" wrote in message ... Hi Tom, Thanks for the program, however the following statement is highlighted in red followed by this error message: Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long Compile Error: Expected: list separator or ) Cheers Carlton *** Sent via Developersdex http://www.developersdex.com *** |
#18
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
|
#19
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Sound to Program
Hi Bob,
I tried to add sound to the following excel program however I keep on getting an error message saying "Sub or Function not defined". Can you help? Private Sub Worksheet_Calculate() Static prevValue If Range("I1").Value prevValue Then PlayWavFile "C:\Windows\Media\Windows XP Print complete" prevValue = Range("I1").Value End If End Sub Cheers Carlton *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is there a way to unload the loaded XLL file in Excel? Hi all, I amdebugging XLL link library using Visual C++. Everytime I rebuild the XLL, Ihave to close the whole Excel program and relaunch the Excel program again,and then load in the newly gene | Excel Discussion (Misc queries) | |||
adding sound to an excel i.e. warning if data is negative | Excel Discussion (Misc queries) | |||
Adding an embedded sound? | Excel Discussion (Misc queries) | |||
This may sound stupid..... | Excel Programming | |||
merging excel program with tdc finance program | Excel Programming |