|
View previous topic :: View next topic |
Author |
Message |
ddh Silver Member
Joined: 17 Nov 2006 Posts: 10
|
Posted: Fri Nov 17, 2006 11:39 am Post subject: Path |
|
|
I have been trying to make the code work on the "Sound in a cell".
I have been having a problem with the
WAVFile = ThisWorkbook.Path & "\sound.wav" 'Edit this statement
I have tried replacing the ThisWorkbook.Path with
WAVFile = Documents And Settings \ Owner \ Desktop \ ExcelSamplesAA & "\drumroll.wav"
and it has not worked I have the Excel file located on the Desktop (not a shortcut)
The path on the properties on the Excel sheet is
C:\Documents and Settings\Owner\Desktop
and the file name is Excel SamplesAA
I have tried so many different varriations and I cannot figure it out.
I have also used Windows \ Media \ ExcelSamplesAA & "\drumroll.wav"
Would you please help me.
________
[URL=http://www.dodge-wiki.com/wiki/List_of_AMC_engines]List of AMC engines history[/URL]
Last edited by ddh on Tue Feb 01, 2011 12:23 pm; edited 1 time in total |
|
Back to top |
|
|
Anthony Site Admin
Joined: 29 Sep 2004 Posts: 36 Location: New York, USA
|
Posted: Mon Nov 20, 2006 3:17 am Post subject: |
|
|
ddh,
Try this:
Public Declare Function PlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal SoundName As String, _
ByVal Flags As Long) As Long
Sub StartSoung()
Call PlaySound ("C:\My Music\SWISH.WAV", 0)
End Sub |
|
Back to top |
|
|
ddh Silver Member
Joined: 17 Nov 2006 Posts: 10
|
Posted: Mon Nov 20, 2006 7:11 am Post subject: Path |
|
|
I don't understand how this code will work to make a sound in a cell.
I pasted it in and nothing happened.
Here is the entire code of what I was working on.
WAVFile = Windows \ Media & "\drumroll.wav" 'Edit this statement
this is the part that I can not make work.
Thank you very much for your help.
ddh
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 = Windows \ Media & "\drumroll.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = True
Exit Function
End If
ErrHandler:
Alarm = False
End Function
________
[URL=http://www.toyota-wiki.com/wiki/Toyota_T100]Toyota T100 specifications[/URL]
Last edited by ddh on Tue Feb 01, 2011 12:23 pm; edited 1 time in total |
|
Back to top |
|
|
ddh Silver Member
Joined: 17 Nov 2006 Posts: 10
|
Posted: Mon Nov 20, 2006 7:25 am Post subject: Path |
|
|
I don't have a file named "My Music"
My path is Windows \ Media \ & "\drumroll.wav"
In the cell I type in =alarm(A1,">1000")
This should make the cell make a sound when a number larger then 1000
is entered into A1. It makes a sound now but it is the system default sound and not the drumroll or some other sound that I want.
I have treid this also WAVFile = ("C:\windows\media\drumroll.wav")
and it did not work.
Thank you for your help.
Call PlaySound("C:\My Music\ding.WAV", 0)
________
[URL=http://trichomes.org/marijuana-strains/og-kush]og kush pictures[/URL]
Last edited by ddh on Tue Feb 01, 2011 12:24 pm; edited 1 time in total |
|
Back to top |
|
|
Anthony Site Admin
Joined: 29 Sep 2004 Posts: 36 Location: New York, USA
|
Posted: Mon Nov 20, 2006 3:25 pm Post subject: |
|
|
I do not think you can really activate the sound from a build-in function on the sheet.
To play the sound when a specific cell is the active cell, you have to put the code in the Sheet Event:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address = "$A$1" Then
Call sndPlaySound32("C:\My Music\SWISH.WAV", 0)
End If
End Sub
Then when you move your cursor to A1, the sound will play.
Also, try to use something like "c:\Documents And Settings\Owner\Desktop\ExcelSamplesAA\drumroll.wav"
instead. |
|
Back to top |
|
|
ddh Silver Member
Joined: 17 Nov 2006 Posts: 10
|
Posted: Mon Nov 20, 2006 3:47 pm Post subject: Path |
|
|
Anthony - Thank you so much for your help.
Please go to the link that I have below.
That is where I got the code from.
I tried "c:\Documents And Settings\Owner\Desktop\ExcelSamplesAA\drumroll.wav"
and it still give the default sound.
ddh
http://j-walk.com/ss/excel/tips/tip87.htm
________
[URL=http://www.cyclechaos.com/wiki/Honda_GL1800]Honda GL1800[/URL]
Last edited by ddh on Tue Feb 01, 2011 12:24 pm; edited 1 time in total |
|
Back to top |
|
|
ddh Silver Member
Joined: 17 Nov 2006 Posts: 10
|
Posted: Tue Nov 28, 2006 9:08 pm Post subject: Cell Sound |
|
|
It still plays the same sound if I copy the the SHEET CODE and change the Title from "Calculate" to "CaculateB" the cell location from A1 to A2.
I also found that if I want a letter all I have to do is "A" as for numbers ">100"
Thank you for your help.
ddh
IN CELL A1 (=C1)
IN CELL C1 is the formula or caculation results.
(THIS CODE IS IN A MODULE)
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
(THIS CODE IS IN SHEET (tab) CODE)
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal uFlags As Long) As Long
Private Sub Worksheet_Calculate()
If Range("A1") = "A" Then Call sndPlaySound32("c:\windows\media\trompet.wav", 1)
Application.Wait Now + TimeSerial(0, 0, 2)
End Sub
________
[URL=http://homemadevaporizers.info/]homemade vaporizers[/URL]
Last edited by ddh on Tue Feb 01, 2011 12:24 pm; edited 1 time in total |
|
Back to top |
|
|
ddh Silver Member
Joined: 17 Nov 2006 Posts: 10
|
Posted: Mon Dec 04, 2006 5:18 pm Post subject: Cell Sound |
|
|
This works except for B2, it has the sound and speech from A2.
Do you have any idea what is wrong.
Thank you for the help.
ddh
[code]
Private Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim strSound As String
Dim strtalk As String
If Not Intersect(Target, Range("$A$1,$A$2,$A$3,$A$4,$A$5,$A$6,$B$2")) Is Nothing Then
strSound = Choose(Target.Row, "tada", "ding", "tada", "beep", "ding", "beep", "Tada")
strtalk = Choose(Target.Row, "Dog", "Cat", "Pig", "House", "cat", "Rat", "Horse")
If Target.Value > 10 Then
sndPlaySound "C:\WINDOWS\Media\" & strSound, 0
End If
If Target.Value < 10 Then
Application.Speech.Speak strtalk
End If
End If
End Sub
[/code]
________
[URL=http://www.ford-wiki.com/wiki/Ford_Starliner]Ford Starliner specifications[/URL] |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|