Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel VBA: how to use the "Wait" command
Excel VBA: how to use the "Wait" command
Resolved · Medium Priority · Version 2003
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?
For upcoming training course dates see: Pricing & availability
RE: Excel VBA: how to use the "Wait" command
Hi KatieThanks 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
|
|
» Forum post: Setting up a project, essential first checks |
The Key To The Perfect Presentation Is Always You Isn't labour-saving technology wonderful? It's certainly grown to play a huge role in the way presentations are made, across business, academia, politics, science and the arts. However, the role of computers needs to be limited, and the human element must remain at the heart of the presentation if it's to have the best possible impact. » Article: Presentation skills london |



Course updates

