[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SendKeys Skipping the first send

Posted on 1999-01-20
5
Medium Priority
?
173 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 300 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month18 days, 15 hours left to enroll

834 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