Sound repeats unending until closing workbook

H

Howard

On Sheet 1 I have two shapes with

Sub A_1_up() assigned to one.
Sub A_1_Down() assigned to the other.

If I click either shape it plays the sound in either F1 or G1 but it goes into a continuous loop and plays the sound repeatedly until I close the workbook.
I have copied the sound portions of code from a workbook that operates justfine, playing the sound just once albeit from a worksheet change event macro. That is, there are several sounds listed in a drop down and when a sound is selected it plays that sound once only.

I am lost as to why the repeated playing. The code below is the ONLY code in the entire workbook.

Thanks,
Howard

In a standard module I have this:

Option Explicit

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

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_LOOP = &H8
Const SND_PURGE = &H40

Public Sub SoundPlayAsyncLoop(Sound As String)
sndPlaySound Sound, SND_ASYNC Or SND_LOOP
End Sub

Public Sub SoundPlayAsyncOnce(Sound As String)
sndPlaySound Sound, SND_ASYNC
End Sub


In the Sheet1 module I have this:

Option Explicit

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Status As Boolean

Sub A_1_up()

Range("A1").Value = Range("A1").Value + 1
SoundPlayAsyncLoop Sheets("Sheet1").Range("F1").Text

End Sub

Sub A_1_Down()

Range("A1").Value = Range("A1").Value - 1
SoundPlayAsyncLoop Sheets("Sheet1").Range("G1").Text

End Sub

On the sheet I have this:

In F1 C:\Windows\Media\ringout.wav
In G1 C:\Windows\Media\Speech Off.wav
 
C

Claus Busch

Hi Howard,

Am Fri, 21 Jun 2013 02:15:58 -0700 (PDT) schrieb Howard:
SoundPlayAsyncLoop Sheets("Sheet1").Range("F1").Text
SoundPlayAsyncOnce Sheets("Sheet1").Range("F1").Text
SoundPlayAsyncLoop Sheets("Sheet1").Range("G1").Text
SoundPlayAsyncOnce Sheets("Sheet1").Range("G1").Text


Regards
Claus Busch
 
H

Howard

Hi Howard,



Am Fri, 21 Jun 2013 02:15:58 -0700 (PDT) schrieb Howard:




SoundPlayAsyncOnce Sheets("Sheet1").Range("F1").Text




SoundPlayAsyncOnce Sheets("Sheet1").Range("G1").Text





Regards

Claus Busch

Well, I sorta was on the right track. I copied from this part of code and missed the part about "SoundStop". Even being curious about the ...Loop portion, it slipped by me.

My bad, DUH! And I thank you for pointing out the obvious.

Regards,
Howard

If .Value <= WarningTime Then
SoundPlayAsyncLoop Sheets("Main").Range("F1").Text
End If
Wend
If (.Value <= Period) Then
SoundStop
.Value = "Time Up!"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Assign a sound to a variable 19
Wavfile playing trubcated 3
Adding sount to a macro 11
How to tell when Beep sound is done? 2
sound 4
Alarm 2 2
Playing wavfiles from excel 3
playing wma files 2

Top