Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to get back the control
Hi,
I have a user form with command buttons cmdPlay and cmdExit. cmdPlay_Click has the following code: Private Sub cmdPlay_Click() sndPlaySound32 "C:Welcom98.wav", 0 End Sub This wave file plays for 30 seconds. cmdExit_Click has the following code: Private Sub cmdExit_Click() End End Sub After clicking cmdPlay, if I am clicking cmdExit then the program is not ending immediately. It is waiting for the wave file to finish playing for 30 seconds. Is it possible that when cmdExit is clicked, within 30 seconds, then the program should end immediately rather than waiting for the whole 30 seconds. Thanks & Regards, Prasad Vanka |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to get back the control
Prasad Vanka
Not really sure, but did you set the command buttons take focus o click to false? HTH Charle -- Message posted from http://www.ExcelForum.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to get back the control
Hi Charles,
I haven't set the command buttons take focus on click to false. regards, Prasad Vanka *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to get back the control
Hi Prasad,
Firstly, you need to play the sound asynchronously, otherwise no code will be able to run until the sound is finished playing. Secondly, if you call sndPlaySound using vbNullString instead of a wav file, it will terminate any other sound that happens to be playing. And last but not least, there's a zillion vb'ers who'll tell you that using End is asking for trouble. Far safer to unload your userform. See an example below. Regards, Vic Eldridge Private Const SND_ASYNC = &H1 Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Private Sub cmdPlay_Click() sndPlaySound "C:\WINNT\Media\Windows Logon Sound.WAV", SND_ASYNC End Sub Private Sub cmdExit_Click() sndPlaySound vbNullString, 0 Unload Me End Sub (Prasad Vanka) wrote in message om... Hi, I have a user form with command buttons cmdPlay and cmdExit. cmdPlay_Click has the following code: Private Sub cmdPlay_Click() sndPlaySound32 "C:Welcom98.wav", 0 End Sub This wave file plays for 30 seconds. cmdExit_Click has the following code: Private Sub cmdExit_Click() End End Sub After clicking cmdPlay, if I am clicking cmdExit then the program is not ending immediately. It is waiting for the wave file to finish playing for 30 seconds. Is it possible that when cmdExit is clicked, within 30 seconds, then the program should end immediately rather than waiting for the whole 30 seconds. Thanks & Regards, Prasad Vanka |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2007 Form Control/ActiveX Control font difference | Excel Discussion (Misc queries) | |||
copy back macro/roll back | Excel Worksheet Functions | |||
Pass control back to Excel window | Excel Worksheet Functions | |||
Set Focus Problem for textbox control on multipage control | Excel Programming | |||
Calendar Control: Can't exit design mode because control can't be created | Excel Programming |