![]() |
Sound repeats unending until closing workbook
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 just fine, 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 |
Sound repeats unending until closing workbook
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 -- Win XP PRof SP2 / Vista Ultimate SP2 Office 2003 SP2 /2007 Ultimate SP2 |
Sound repeats unending until closing workbook
On Friday, June 21, 2013 2:38:45 AM UTC-7, Claus Busch wrote:
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 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 |
All times are GMT +1. The time now is 04:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com