Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Adding Sound to Program

Hee hee,

I should've seen that.

Cheers mate.

Carlton

*** Sent via Developersdex http://www.developersdex.com ***
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Adding Sound to Program

Hi Bob,


Thats great mate.

Cheers mate

Carlton

*** Sent via Developersdex http://www.developersdex.com ***


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Adding Sound to Program

Bob,

Thanks a lot mate.

Cheers

Carlton

*** Sent via Developersdex http://www.developersdex.com ***
  #19   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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
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
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 LunaMoon Excel Discussion (Misc queries) 0 July 28th 08 11:03 PM
adding sound to an excel i.e. warning if data is negative CDG Excel Discussion (Misc queries) 6 March 11th 06 10:39 PM
Adding an embedded sound? Terry Pinnell Excel Discussion (Misc queries) 0 September 5th 05 12:50 PM
This may sound stupid..... anthonyenglish Excel Programming 3 October 14th 04 07:05 PM
merging excel program with tdc finance program judy Excel Programming 0 November 5th 03 08:01 PM


All times are GMT +1. The time now is 06:40 PM.

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"