Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 Form Control/ActiveX Control font difference Nikko963 Excel Discussion (Misc queries) 0 April 15th 09 04:21 PM
copy back macro/roll back moh Excel Worksheet Functions 4 March 5th 07 02:19 PM
Pass control back to Excel window [email protected] Excel Worksheet Functions 1 December 29th 06 07:24 PM
Set Focus Problem for textbox control on multipage control ExcelDeveloperSPR Excel Programming 1 July 16th 04 08:54 PM
Calendar Control: Can't exit design mode because control can't be created Rone Excel Programming 0 May 24th 04 04:01 PM


All times are GMT +1. The time now is 10:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"