Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wait for 2 seconds 1

Status
Not open for further replies.

JamieArvato

Technical User
Aug 5, 2004
50
GB
I'm running print all sheets code and for some reason it is not printing the sheets in order.......

I want to put in a 1 second wait in the Next Print function to allow each sheet to go to the printer in order.

Thanks
 
goto VBE
Press F1
type "Wait"
read results

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Have'nt got the help files installed and the network does not allow an instal.

Can anybody post it as I need something asap.

Thanks.
 
Try:
Code:
newHour = Hour(Now())
newMinute = Minute(Now()) 
newSecond = Second(Now()) + 2
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
 
Whilst this would take about 5 seconds to download from google, here is the extract from the help file. I would strongly suggest you get your IT dept to install your help files as this is NOT a helpdesk site:

Wait Method
See Also Applies To Example Specifics
Pauses a running macro until a specified time. Returns True if the specified time has arrived.

Important The Wait method suspends all Microsoft Excel activity and may prevent you from performing other operations on your computer while Wait is in effect. However, background processes such as printing and recalculation continue.

expression.Wait(Time)

expression Required. An expression that returns an Application object.

Time Required Variant. The time at which you want the macro to resume, in Microsoft Excel date format.

Example
This example pauses a running macro until 6:23 P.M. today.

Application.Wait "18:23:00"
This example pauses a running macro for approximately 10 seconds.

newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
This example displays a message indicating whether 10 seconds have passed.

If Application.Wait(Now + TimeValue("0:00:10")) Then
MsgBox "Time expired"
End If


Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Could you possibly use

Application.ontime now + timevalue("00:00:01")

somewhere in a loop?

This would allow Excel to continue running and put a 1 second delay in the process


Merry Part and the Brightest of Blessings

With respect
Wicca
-----
IF you think you can
Or
If you think you can't
Then
You are probably right
-Henry Ford
 
This works for me.

Public Function Pause(Delay As Double, Optional Increment As String)
'Example: Pause (3) will delay program continuation for 3 seconds
'Created by RGB 10 May, 2001
'Modified by RGB 10 July, 2002 - added Increment option
'Example: Pause (3,"S") will delay program continuation for 3 seconds
'Example: Pause (3,"M") will delay program continuation for 3 minutes
'Example: Pause (3,"H") will delay program continuation for 3 hours

Dim PauseTime, Start, Finish, TotalTime
If Increment = "" Then Increment = "S"
Select Case Increment
Case Is = "S" ' Sets length of pause for seconds.
PauseTime = Delay
Case Is = "M" ' Sets length of pause for minutes.
PauseTime = Delay * 60
Case Is = "H" ' Sets length of pause for hours.
PauseTime = Delay * 3600
Case Else 'Checks for valid Increment value and displays message box in invalid
MsgBox "Pause(" & Delay & ") - Defaults to seconds." & vbCr _
& "Pause(" & Delay & ",""S"")" & vbCr _
& "Pause(" & Delay & ",""M"")" & vbCr _
& "Pause(" & Delay & ",""H"")" & vbCr _
& "Are the only valid values - please re-enter and try again."
Exit Function
End Select

'Here's where the delay starts
Start = Timer ' Starts the delay.
Do While Timer < Start + PauseTime
DoEvents ' Let other stuff run while paused.
Loop

End Function
 
I would like something like this I think... I need to have my macro wait to continue until a print job is done as I then close the document and application that I sent to the printer.

I use another program - Extra Basic - to write the macro that does this. So I would need to adjust the code to fit my application.

Bottom line is How do I know when it is safe to close a document once I've sent it to the printer. Is there some sort of return code that lets me know the printer accepted the job, etc.? Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top