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
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