Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
sparky
 
Posts: n/a
Default sound clip as a result of conditional formatting... ?

Does anyone know if it is possible to have Excel play a sound clip as a
result of conditional formatting... ? Or maybe as a macro ?

I'm a fairly junior Excel user, so go easy, k ?
  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default sound clip as a result of conditional formatting... ?

You can play a sound with a VBA call to a Windows API:


Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub AAA()
sndPlaySound32 "chimes.wav", 0
End Sub

Change "chimes.wav" to the sound file you want to play.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"sparky" wrote in message
...
Does anyone know if it is possible to have Excel play a sound
clip as a
result of conditional formatting... ? Or maybe as a macro ?

I'm a fairly junior Excel user, so go easy, k ?



  #3   Report Post  
Posted to microsoft.public.excel.misc
sparky
 
Posts: n/a
Default sound clip as a result of conditional formatting... ?

Really appreciate your help, Chip!

....not certain where/how to insert this code, however.
can you spare another moment to tell me ??

Thx again,
JohnC



"Chip Pearson" wrote:

You can play a sound with a VBA call to a Windows API:


Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub AAA()
sndPlaySound32 "chimes.wav", 0
End Sub

Change "chimes.wav" to the sound file you want to play.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"sparky" wrote in message
...
Does anyone know if it is possible to have Excel play a sound
clip as a
result of conditional formatting... ? Or maybe as a macro ?

I'm a fairly junior Excel user, so go easy, k ?




  #4   Report Post  
Posted to microsoft.public.excel.misc
David McRitchie
 
Posts: n/a
Default sound clip as a result of conditional formatting... ?

Hi John, (this is old from Dec 3rd to 5th but it looked like you are waiting for an answer)

You did not really describe what you wanted to do.

What Chip gave you was macro code that you can invoke a macro
to play a chime (which you asked for), but you can't use it in Conditional Formatting.
You can read more about Conditional Formatting in
http://www.mvps.org/dmcritchie/excel/condfmt.htm
but be aware that playing a chime is not formatting so you can't
use Conditional Formatting.

Since you want a chime it is probably to be used as an error condition
that you want them to correct the data just entered in error, in which case you
probably want to look at cell validation. (try the Flash presentation first)
http://www.mvps.org/dmcritchie/excel/validation.htm
http://www.contextures.com/tiptech.html -- Data Validation
http://www.datapigtechnologies.com/ExcelMain.htm -- Data Validation [Flash presentation]
Additional places to find Excel Tutorials on
http://www.mvps.org/dmcritchie/excel....htm#tutorials

If you want to do something yourself using a Change Event macro

Install Chip's code at the TOP of a standard module -- a new module in your personal.xls would be fine
as the declarations above the SUB should be at the top. I'll change the name
from AAA to chimes. If you have never installed a macro in your personal.xls
see http://www.mvps.org/dmcritchie/excel/getstarted.htm
additional help in calling a function or a macro in
http://www.mvps.org/dmcritchie/excel/install.htm

Option Explicit
Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub chimes()
sndPlaySound32 "chimes.wav", 0
End Sub


You can call that macro from another macro
Application.Run "personal.xls!chimes"

You could for instance call it from an Event macro, which cannot
have your Function in it but you can call a macro that uses the function.
More on Event macros in
http://www.mvps.org/dmcritchie/excel/event.htm

Two event macros examples one for a double-click and one
to chime if not numeric or number is greater than 360.

Install as a worksheet macro by right click on sheet tab
then "View Code" and then insert the following code.

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.Run "personal.xls!chimes"
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
On Error GoTo errors
If Target.Value 360 Then GoTo errors
End If
Exit Sub
errors:
On Error GoTo 0
Application.Run "personal.xls!chimes"
End Sub

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"sparky" wrote in message ...
Really appreciate your help, Chip!

...not certain where/how to insert this code, however.
can you spare another moment to tell me ??

Thx again,
JohnC



"Chip Pearson" wrote:

You can play a sound with a VBA call to a Windows API:


Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub AAA()
sndPlaySound32 "chimes.wav", 0
End Sub

Change "chimes.wav" to the sound file you want to play.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"sparky" wrote in message
...
Does anyone know if it is possible to have Excel play a sound
clip as a
result of conditional formatting... ? Or maybe as a macro ?

I'm a fairly junior Excel user, so go easy, k ?






  #5   Report Post  
Posted to microsoft.public.excel.misc
jeffP
 
Posts: n/a
Default sound clip as a result of conditional formatting... ?

David,
Great info. Thanks. I'm still in need.I love to add sounds & wav files to
worksheet or workbook opens etc. My problem is I want to sent a workbook to
someone via email attachment and therefore I lose the wav file referred to in
the macro. Any idea how to "attach" or "imbed" the related files to the
workbook?

Any help is always appreciated.
Jeff


"David McRitchie" wrote:

Hi John, (this is old from Dec 3rd to 5th but it looked like you are waiting for an answer)

You did not really describe what you wanted to do.

What Chip gave you was macro code that you can invoke a macro
to play a chime (which you asked for), but you can't use it in Conditional Formatting.
You can read more about Conditional Formatting in
http://www.mvps.org/dmcritchie/excel/condfmt.htm
but be aware that playing a chime is not formatting so you can't
use Conditional Formatting.

Since you want a chime it is probably to be used as an error condition
that you want them to correct the data just entered in error, in which case you
probably want to look at cell validation. (try the Flash presentation first)
http://www.mvps.org/dmcritchie/excel/validation.htm
http://www.contextures.com/tiptech.html -- Data Validation
http://www.datapigtechnologies.com/ExcelMain.htm -- Data Validation [Flash presentation]
Additional places to find Excel Tutorials on
http://www.mvps.org/dmcritchie/excel....htm#tutorials

If you want to do something yourself using a Change Event macro

Install Chip's code at the TOP of a standard module -- a new module in your personal.xls would be fine
as the declarations above the SUB should be at the top. I'll change the name
from AAA to chimes. If you have never installed a macro in your personal.xls
see http://www.mvps.org/dmcritchie/excel/getstarted.htm
additional help in calling a function or a macro in
http://www.mvps.org/dmcritchie/excel/install.htm

Option Explicit
Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub chimes()
sndPlaySound32 "chimes.wav", 0
End Sub


You can call that macro from another macro
Application.Run "personal.xls!chimes"

You could for instance call it from an Event macro, which cannot
have your Function in it but you can call a macro that uses the function.
More on Event macros in
http://www.mvps.org/dmcritchie/excel/event.htm

Two event macros examples one for a double-click and one
to chime if not numeric or number is greater than 360.

Install as a worksheet macro by right click on sheet tab
then "View Code" and then insert the following code.

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.Run "personal.xls!chimes"
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
On Error GoTo errors
If Target.Value 360 Then GoTo errors
End If
Exit Sub
errors:
On Error GoTo 0
Application.Run "personal.xls!chimes"
End Sub

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"sparky" wrote in message ...
Really appreciate your help, Chip!

...not certain where/how to insert this code, however.
can you spare another moment to tell me ??

Thx again,
JohnC



"Chip Pearson" wrote:

You can play a sound with a VBA call to a Windows API:


Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub AAA()
sndPlaySound32 "chimes.wav", 0
End Sub

Change "chimes.wav" to the sound file you want to play.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"sparky" wrote in message
...
Does anyone know if it is possible to have Excel play a sound
clip as a
result of conditional formatting... ? Or maybe as a macro ?

I'm a fairly junior Excel user, so go easy, k ?








  #6   Report Post  
Posted to microsoft.public.excel.misc
David McRitchie
 
Posts: n/a
Default sound clip as a result of conditional formatting... ?

Hi Jeff, (posted to excel.misc)
Hopefully you would only ever send the wave file once, and I expect
people would only want one copy. i.e. c:\winnt\system32\winmm.dll
so other than a note as to where they might install the .wav file
I don't see packaging them in the same email if your are going to
update the Excel file regularly. The example given was one
that they would already have.

Anyway I wouldn't know how to automatically search the system for
the .dll and include it in the email.

As far a embedding them in a workbook don't know how, aren't the
big enough now. Using those keywords though here is a posting
by Chip Pearson using OLEObjects.Add have no idea whether
it does what you want.
http://groups.google.com/groups?thre...%40tkmsftngp02

--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"jeffP" wrote...
My [additional] problem is I want to send a workbook to
someone via email attachment and therefore I lose the wav file referred to in
the macro. Any idea how to "attach" or "imbed" the related files to the
workbook?



  #7   Report Post  
Posted to microsoft.public.excel.misc
jeffP
 
Posts: n/a
Default sound clip as a result of conditional formatting... ?

David,
I wasn't thinking so much of the winmn.dll but the wav file itself( ie audio
into notes to Joe.wav) that I would like to open when he opens the workbook.
Yes, a repetitive workbook would make sense to send the wav file separtately
but a one time workbook......
I'll check your suggested link on OLE objects and again thanks.

"David McRitchie" wrote:

Hi Jeff, (posted to excel.misc)
Hopefully you would only ever send the wave file once, and I expect
people would only want one copy. i.e. c:\winnt\system32\winmm.dll
so other than a note as to where they might install the .wav file
I don't see packaging them in the same email if your are going to
update the Excel file regularly. The example given was one
that they would already have.

Anyway I wouldn't know how to automatically search the system for
the .dll and include it in the email.

As far a embedding them in a workbook don't know how, aren't the
big enough now. Using those keywords though here is a posting
by Chip Pearson using OLEObjects.Add have no idea whether
it does what you want.
http://groups.google.com/groups?thre...%40tkmsftngp02

--
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"jeffP" wrote...
My [additional] problem is I want to send a workbook to
someone via email attachment and therefore I lose the wav file referred to in
the macro. Any idea how to "attach" or "imbed" the related files to the
workbook?




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
Conditional Formatting sweetsue516 Excel Discussion (Misc queries) 7 September 20th 05 08:16 PM
Conditional Formatting Error ddate Excel Worksheet Functions 0 May 5th 05 09:00 PM
difficulty with conditional formatting Deb Excel Discussion (Misc queries) 0 March 23rd 05 06:13 PM
conditional formatting question Deb Excel Discussion (Misc queries) 0 March 23rd 05 02:07 AM
Copy conditional formatting across multiple rows? Gil Excel Discussion (Misc queries) 1 January 11th 05 11:27 AM


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