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

excel vba use wait

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

ResolvedVersion 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:

Bracketed negative numbers

Often Excel users wish to display negative numbers in colour red and bracketed

Intstructions
Step1. Select Format > Cells menu options. Within Numbers tabsheet, select Category = Custom.
Step 2. Select a type such as #,##0;[Red]-#,##0;; that specifies a colour in square brackets.
Step 3. Amend as follows; #,##0;[Red](#,##0;;

Notes: Excel formatting featues are of the form
"Positive; Negative;Zero;Text" separated by semicolon.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.