Solved

SendKeys Skipping the first send

Posted on 1999-01-20
5
158 Views
Last Modified: 2012-05-04
This is the first part of my program.  The first TAB will not function. There are other TABs in the program that do work. I have tried putting a timer after the App is Activated.

Private Sub Command1_Click()
    AppActivate "Merchant Management", True
    SendKeys "{tab}", True
    SendKeys "E", True
0
Comment
Question by:matthewkwp
5 Comments
 
LVL 4

Accepted Solution

by:
chabaud earned 100 total points
ID: 1469673
Try this alternate code (which send Alt+E):

AppActivate "Merchant Management", True
SendKeys "%E", True
0
 
LVL 3

Expert Comment

by:sduckett
ID: 1469674
I've tested very similar code using Word instead of your app as I don't have "Merchant Management".
The code works, but it does depend on the state of the App at the time the code is run. eg. If the cursor is in a document at the time it runs a tab is placed there, if a dialog box is open, a tab is sent to that dialog box.
Can you be confident that the app is in the state you expect at all times? What actually happens if you switch to Merchant Management and press 'tab'?

0
 
LVL 12

Expert Comment

by:mark2150
ID: 1469675
Yeah, SendKeys tends to be state dependent. You're much safer sending explicit Ctrl-this, Alt-that's than assuming that "two tabs" are going to activate some function.

M

0
 

Author Comment

by:matthewkwp
ID: 1469676
Alt/Ctrl won't work.  I also tried this in a 'Notepad' Window and had the same results.
0
 
LVL 4

Expert Comment

by:chabaud
ID: 1469677
Try insert DoEvents statement between your SendKeys.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Use Multiple Forms 4 57
VBA: Select SQL query based on a config Sheet v2 11 44
Prevent checkbox click event occur while editing it in vb6 8 41
Added a column screws up code 5 57
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question