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!

How to pause while sending keys 1

Status
Not open for further replies.

TheMus

Technical User
Aug 23, 2000
28
US
I'm sending keys from access to another application so I can FTP a file. Everything works fine until the SendKeys accesses the FTP site which takes a second or two. Is there a way to send a second or two pause via code so the code will wait until the FTP site is displayed completely?

Thanks in advance. [sig][/sig]
 
From the Help File

SendKeys Action
The SendKeys action has the following arguments.
Keystrokes: The keystrokes you want Microsoft Access or the application to process. Enter the keystrokes in the Keystrokes box in the Action Arguments section of the Macro window. You can type up to 255 characters. This is a required argument.

Wait: Specifies whether the macro should pause until the keystrokes have been processed. Click Yes (to pause) or No (not to pause). The default is No.


Are you setting the wait action to YES ???


PaulF
[sig][/sig]
 
PaulF, thanks for the response. Yes the Wait argument is set to Yes. The action does wait until the keys are processed, but it takes the FTP site a bit longer to fully display so the next SendKeys processes before the FTP site is finished. [sig][/sig]
 
I picked the following up somewhere out there on the web, not sure where at,so I can't give credit where credit is due..... hope this helps.. if not there's a function I picked up call ShellAndWait that might be of help.



Make code go to Sleep

More than a few people have asked me if an alternative to DoEvents
exists to implement a wait period in Access. (DoEvents yields execution
so that the operating system can process other events.)

The answer is yes, the Sleep API can be used for this. Look at the
sample sTestSleep Sub. When you run it, you'll notice a delay beforethe
Msgbox appears on screen. The duration can be increased/decreased
bychanging the constant cTime to a corressponding higher/lower value.

For normal use from within your code, simply place a call to the sSleep
sub with an appropriate time in milliseconds.

'***************** Code Start *******************
Private Declare Sub sapiSleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Sub sSleep(lngMilliSec As Long)
If lngMilliSec > 0 Then
Call sapiSleep(lngMilliSec)
End If
End Sub

Sub sTestSleep()
Const cTIME = 1000 'in MilliSeconds
Call sSleep(cTIME)
MsgBox "Before this Msgbox, I was asleep for " _
& cTIME & " Milliseconds."
End Sub
'***************** Code End *********************



HTH
PaulF [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top