excel vba use wait

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

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

resolvedResolved · 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?

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

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Applying and removing border from cell in Excel 2010

Did you know the shortcut key for applying and removing the outline border for a cell?

CTRL+SHIFT+& Applies the outline border to the selected cells.
CTRL+SHIFT_ Removes the outline border from the selected cells.

View all Excel hints and tips


Server loaded in 0.08 secs.