Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
play sound when closing xcel 2007 | Excel Discussion (Misc queries) | |||
copy and paste VBA repeats and repeats | Excel Discussion (Misc queries) | |||
Closing a workbook from a macro doesn't close the workbook | Excel Programming | |||
play sound when opening workbook | Excel Programming | |||
closing excel after closing a workbook | Excel Programming |