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

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
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:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top