Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Wait for action

Hallo!

I want to make a macro that show a userform with a button.
If the user have not clicked the button within 15 sec I want the code to
continue.
If the user click the button the code will end.

Thanks for any help!

Johan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Wait for action


What closes the userform is the HIDE method. Normally you put the HIDE
into the click function but you can put it anyplace in the code. You
need to start a timer function when you open the form in an initialize
routine. and stop the timer when you close the form. the Timer
Procedure must be in a module, not in the userform. You also need to
stop the timer if the button is pressed.

below is the module code

Sub test()

UserForm1.Show
Call nextsub
End Sub

Sub my_procedure()

UserForm1.Hide
Call nextsub

End Sub


-----------------------------------------
Put this code into the userform


Sub Userform_Initialize()

Application.OnTime Now + TimeValue("00:00:15"), "my_Procedure"

End Sub

Private Sub CommandButton1_Click()
'code to stop the timer if the button is pressed.
Application.OnTime EarliestTime:=Now, _
Procedu="my_Procedure", Schedule:=False

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=157409

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Wait for action

Thanks for your help joel, however the code goes to Error and gives the
following message:

Run-time error '1004':
Metode 'OnTime' of Object'_Application' failed

Any help on that?

Thanks
Johan

joel skrev:


What closes the userform is the HIDE method. Normally you put the HIDE
into the click function but you can put it anyplace in the code. You
need to start a timer function when you open the form in an initialize
routine. and stop the timer when you close the form. the Timer
Procedure must be in a module, not in the userform. You also need to
stop the timer if the button is pressed.

below is the module code

Sub test()

UserForm1.Show
Call nextsub
End Sub

Sub my_procedure()

UserForm1.Hide
Call nextsub

End Sub


-----------------------------------------
Put this code into the userform


Sub Userform_Initialize()

Application.OnTime Now + TimeValue("00:00:15"), "my_Procedure"

End Sub

Private Sub CommandButton1_Click()
'code to stop the timer if the button is pressed.
Application.OnTime EarliestTime:=Now, _
Procedu="my_Procedure", Schedule:=False

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=157409

Microsoft Office Help

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Wait for action


Make sure the code matches exactly what appeas in the posting. I fully
tested this code with 2003. The Procedure Name "My_Procedure" on the
line and the procedure code in the Module must match.

I tried to duplicate the error and cannot which make me believe the
problem is a simple typo error.


Try typing "application." without the double quotes (with a period at
the end) and check in the pop up window to see in "ONTIME" appears. I
want to see if all the libraries are installed on your PC.


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=157409

Microsoft Office Help

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
Excell copy action pauses for 15 second for the smallest action Meekal Excel Discussion (Misc queries) 1 January 28th 10 04:30 PM
sendkeys(keys,wait) how do I use wait MM Excel Discussion (Misc queries) 1 February 11th 09 03:47 PM
When Excel wait for OLE action allow cancel so not have to end pr sferrell615 Excel Discussion (Misc queries) 0 August 4th 06 02:46 PM
pause vba action without using Application.Wait? [email protected] Excel Programming 2 December 21st 05 07:12 PM
wait for user action in VBA code benb Excel Programming 4 September 24th 04 09:05 PM


All times are GMT +1. The time now is 07:27 PM.

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

About Us

"It's about Microsoft Excel"