Send Keys

zocker
08-05-2001, 01:03 PM
I am importing data into an Accounts program called Sage, from Access 2000 The code works except for the three lines hat simulate three down arrow keypresses. Key Presses work but the simulation does not but then works again for the rest of the procedure. Any ideas welcomed.

Regards

Private Sub Command0_Click()

Shell ("C:\sfw\sfw.exe"), vbMaximizedFocus

DoEvents

SendKeys "%F", False ' Send ALT+F to open &File Menu

DoEvents


SendKeys "I", True ' Send I to select 'Import Data'


DoEvents 'Let Windows have a turn & Give SFW.exe a chance to catch up.

SendKeys "{DOWN)" 'Move down one

DoEvents

SendKeys vbKeyDown 'Move down another

DoEvents

SendKeys vbKeyDown 'Move down another

DoEvents

SendKeys "%R" 'When Focus has noved down 3 check boxes then use Alt + R to Run it, this works OK

' SendKeys "(C:\sfw\Barry.csv)"



'MsgBox " Faulty"
Exit Sub



End Sub

Thinker
08-05-2001, 07:20 PM
I don't think you can use vbKeyDown for the down arrow. The first down arrow line has SendKeys "{DOWN)" 'Move down one
This would not work either as you have a ) at the end of DOWN instead of }
If you did a copy and paste to put this code in the post then go back to the program and change ) to } and the other two vbKeyDown to "{DOWN}"

Other than this the next solution is using API calls to send messages. If you do a search for SendMessage, there should already be a number of recent posts explaining this.


I think therefore I am... sometimes right. images/icons/wink.gif

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum