Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excell copy action pauses for 15 second for the smallest action | Excel Discussion (Misc queries) | |||
sendkeys(keys,wait) how do I use wait | Excel Discussion (Misc queries) | |||
When Excel wait for OLE action allow cancel so not have to end pr | Excel Discussion (Misc queries) | |||
pause vba action without using Application.Wait? | Excel Programming | |||
wait for user action in VBA code | Excel Programming |