Excel VBA: how to use the "Wait" command
I understand the command -
Application.Wait Now + TimeValue("00:00:01")
is to pause the macro for 1 second before execution. But it only pauses at the beginning of the macro and not within.
How do I manipulate the line so it will pause in the middle of my macro.
e.g. My Excel macro suppose to wait for the user to choose paper tray before printing. My code so far pauses for 5 seconds at the beginning before it executes...
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub SendKey2Print(prnbin)
' The code below is for copier/printer model: Ricoh 3260C
SendKeys "%(FPR)" 'sets to Print Properties
SendKeys "+{TAB}{RIGHT}" 'switch to tab "Paper"
SendKeys "{TAB 8}" 'switch to input tray
SendKeys "{UP 5}" 'switch to "AutoTray selection"
Application.Wait Now + TimeValue("00:00:05")
SendKeys "{ENTER}"
SendKeys "{ESC}"
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Can anyone help?
RE: Excel VBA: how to use the "Wait" command
Hi Katie
Thanks for the question took some experiments to find a possible solution.
It seems that the culprit is SendKeys. Can you try adding a ",True" to each line, eg
SendKeys "%(FPR)", True
That seems to make the program work in a linear mode rather than doing the Wait first.
Let me know if it works.
Laura GB