Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Application.Wait Not Working ???

I have the following code for pausing before trying an Internet
connection (one of a number of them). However, it just hangs there.
I am using Windows XP and Excel 2003.

Sub WaitSeconds(seconds As Integer)
'
' This subroutine waits for a specified number of seconds.
'
Dim CurrentHour As Integer, CurrentMinute As Integer,
CurrentSecond As Integer
Dim newHour As Integer, newMinute As Integer, newSecond As Integer
Dim waitTime As Integer, CurrentTime As Integer
CurrentHour = Hour(Now())
CurrentMinute = Minute(Now())
CurrentSecond = Second(Now())
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + seconds
waitTime = TimeSerial(newHour, newMinute, newSecond)
Debug.Print "Current time = " & CurrentHour & ":" & CurrentMinute
& _
":" & CurrentSecond
Debug.Print "Waiting until " & newHour & ":" & newMinute & _
":" & newSecond
Application.Wait waitTime
End Sub

Any ideas why it would do this??

I call the subroutine above like this when it hangs:

WaitSeconds (2)

Thanks, Alan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Application.Wait Not Working ???

Alan,

Try this

Sub WaitSeconds(seconds As Integer)
' This subroutine waits for a specified number of seconds.
'
Dim CurrentHour As Integer, CurrentMinute As Integer, CurrentSecond As
Integer
Dim newHour As Integer, newMinute As Integer, newSecond As Integer
Dim waitTime As Variant, CurrentTime As Long
CurrentHour = Hour(Now())
CurrentMinute = Minute(Now())
CurrentSecond = Second(Now())
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + seconds
waitTime = TimeSerial(newHour, newMinute, newSecond)

Debug.Print "Current time = " & CurrentHour & ":" & CurrentMinute & _
":" & CurrentSecond
Debug.Print "Waiting until " & newHour & ":" & newMinute & _
":" & newSecond
Application.Wait waitTime
Debug.Print Now

End Sub

Mike

"Alan" wrote:

I have the following code for pausing before trying an Internet
connection (one of a number of them). However, it just hangs there.
I am using Windows XP and Excel 2003.

Sub WaitSeconds(seconds As Integer)
'
' This subroutine waits for a specified number of seconds.
'
Dim CurrentHour As Integer, CurrentMinute As Integer,
CurrentSecond As Integer
Dim newHour As Integer, newMinute As Integer, newSecond As Integer
Dim waitTime As Integer, CurrentTime As Integer
CurrentHour = Hour(Now())
CurrentMinute = Minute(Now())
CurrentSecond = Second(Now())
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + seconds
waitTime = TimeSerial(newHour, newMinute, newSecond)
Debug.Print "Current time = " & CurrentHour & ":" & CurrentMinute
& _
":" & CurrentSecond
Debug.Print "Waiting until " & newHour & ":" & newMinute & _
":" & newSecond
Application.Wait waitTime
End Sub

Any ideas why it would do this??

I call the subroutine above like this when it hangs:

WaitSeconds (2)

Thanks, Alan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Application.Wait Not Working ???

Use actual date time values

Sub WaitSeconds(Seconds As Integer)
' This subroutine waits for a specified number of seconds.
'
Dim CurrentTime As Date
Dim FinishTime As Date
CurrentTime = Now
FinishTime = Now + Seconds / 24 / 60 / 60

Debug.Print "Current time = " & Format(CurrentTime, "mmm dd, yyyy hh:mm:ss")
Debug.Print "Waiting until " & Format(FinishTime, "mmm dd, yyyy hh:mm:ss")
Application.Wait FinishTime
Debug.Print "I have finished waiting at " & Format(Now, "mmm dd, yyyy hh:mm:ss")

End Sub


HTH,
Bernie
MS Excel MVP


"Alan" wrote in message
...
I have the following code for pausing before trying an Internet
connection (one of a number of them). However, it just hangs there.
I am using Windows XP and Excel 2003.

Sub WaitSeconds(seconds As Integer)
'
' This subroutine waits for a specified number of seconds.
'
Dim CurrentHour As Integer, CurrentMinute As Integer,
CurrentSecond As Integer
Dim newHour As Integer, newMinute As Integer, newSecond As Integer
Dim waitTime As Integer, CurrentTime As Integer
CurrentHour = Hour(Now())
CurrentMinute = Minute(Now())
CurrentSecond = Second(Now())
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + seconds
waitTime = TimeSerial(newHour, newMinute, newSecond)
Debug.Print "Current time = " & CurrentHour & ":" & CurrentMinute
& _
":" & CurrentSecond
Debug.Print "Waiting until " & newHour & ":" & newMinute & _
":" & newSecond
Application.Wait waitTime
End Sub

Any ideas why it would do this??

I call the subroutine above like this when it hangs:

WaitSeconds (2)

Thanks, Alan



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Application.Wait Not Working ???


it seems that you have the application waiting for a time that occurred
prior to executing Application.Wait so (it seems to me) that it would
have to wait 24hrs before releasing, normally you execute the Wait
command like this:
Application.Wait (Now() + TimeValue("00:00:30"))

Alan;263037 Wrote:
I have the following code for pausing before trying an Internet
connection (one of a number of them). However, it just hangs there.
I am using Windows XP and Excel 2003.


Sub WaitSeconds(seconds As Integer)
'
' This subroutine waits for a specified number of seconds.
'
Dim CurrentHour As Integer, CurrentMinute As Integer,
CurrentSecond As Integer
Dim newHour As Integer, newMinute As Integer, newSecond As Integer
Dim waitTime As Integer, CurrentTime As Integer
CurrentHour = Hour(Now())
CurrentMinute = Minute(Now())
CurrentSecond = Second(Now())
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + seconds
waitTime = TimeSerial(newHour, newMinute, newSecond)
Debug.Print "Current time = " & CurrentHour & ":" & CurrentMinute
& _
":" & CurrentSecond
Debug.Print "Waiting until " & newHour & ":" & newMinute & _
":" & newSecond
Application.Wait waitTime
End Sub

Any ideas why it would do this??

I call the subroutine above like this when it hangs:

WaitSeconds (2)

Thanks, Alan



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=73434

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
Application wait question Graeme Excel Programming 4 April 12th 08 07:21 PM
Application.wait... won't! Peter Rooney Excel Programming 12 November 17th 06 04:31 AM
Please help with Application.Wait ( ) Steve[_80_] Excel Programming 2 January 6th 06 01:23 PM
Different syntax for Application.Wait Desert Piranha[_19_] Excel Programming 3 December 16th 05 12:13 PM
application.wait help flowtester Excel Programming 10 December 4th 05 03:47 PM


All times are GMT +1. The time now is 08:42 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"