Application.SendKeys "{TAB 2}" does not work

Nelson78

Active Member
Joined
Sep 11, 2017
Messages
422
Hello everybody.

I'm a newbie about automating external application via sendkeys method.

Now, I can get in the external application, I can write (for example "5"), but I cannot shift the focus two fields on the right (as I manually do without problem). I mean: nothing happens.

Maybe somebody could suggest the solution.

Thank you in advance.

Code:
Application.SendKeys ("5")

Application.Wait (Now + TimeValue("0:00:05"))

Application.SendKeys "{TAB 2}", True
 
Last edited:

Kenneth Hobson

Well-known Member
Joined
Feb 6, 2007
Messages
3,092
I avoid SendKeys() solutions as-much-as possible. It is all about timing and focus. Besides a time wait, one can do a loop wait if one knows the Window's handle. That can be found by API routines sometimes.

Two tab keys works for me.
Code:
Sub Main()
  Dim rc As Integer
  With Application
    rc = Shell("notepad", vbNormalFocus)
    .Wait (Now + TimeValue("0:00:01"))
    .SendKeys ("5"), True
    '.Wait (Now + TimeValue("0:00:05"))
    .SendKeys "{TAB 2}", True
    .SendKeys ("6"), True
  End With
End Sub
 

Nelson78

Active Member
Joined
Sep 11, 2017
Messages
422
I avoid SendKeys() solutions as-much-as possible. It is all about timing and focus. Besides a time wait, one can do a loop wait if one knows the Window's handle. That can be found by API routines sometimes.

Two tab keys works for me.
Code:
Sub Main()
  Dim rc As Integer
  With Application
    rc = Shell("notepad", vbNormalFocus)
    .Wait (Now + TimeValue("0:00:01"))
    .SendKeys ("5"), True
    '.Wait (Now + TimeValue("0:00:05"))
    .SendKeys "{TAB 2}", True
    .SendKeys ("6"), True
  End With
End Sub
In all my life, I have regularly avoided Sendkeys() solution in order to grasp data somewhere else.

But now the task is harder: I have to grasp data from a SIEBEL CRM in which I get in using user and password: so, it has not a url, I have to deal with Citrix, a certificate, etc etc. And furthermore, I cannot detect anything about the activity via Fiddler.
Now, concerning this point, the question is: how can I automate in a stable way the withdraw of data using Excel? (If the operation is feasible without Sendkeys(), of course).

In the meantime, Sendkeys() could be a temporary solution.
 

Kenneth Hobson

Well-known Member
Joined
Feb 6, 2007
Messages
3,092
Have you tried sending a single tab key?

In some other programming languages, I found outside SendKeys() methods did better. I also found that sending one key at a time worked better in some cases. If the above does not work, I can show you an API method to sendkeys.
 

Forum statistics

Threads
1,081,969
Messages
5,362,484
Members
400,677
Latest member
champchamp

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top