I have tried this method before on a browser where I fill in details for a form using Excel VBA, but when I'm trying to use this for a software, it isn't working. It probably shouldn't have anything to do with what I'm using because I'm just using the SendKeys
function when I manually click inside the first text box on the window.
Sub enter_details()
Dim i As Integer
Dim des, name, addr As String
Application.Wait Now + #12:00:05 AM#
For i = 5 To 15
des = Cells(i, 2).Value
name = Cells(i, 3).Value
addr = Cells(i, 4).Value
Application.SendKeys (des)
Application.Wait Now + #12:00:01 AM#
Application.SendKeys ("{TAB}")
Application.Wait Now + #12:00:01 AM#
SendKeys (name)
Application.Wait Now + #12:00:01 AM#
Application.SendKeys ("{TAB}")
.
.
.
Next
End Sub
Can someone please point out what am I doing wrong here?
Thanks in advance!
First some notes: Dim des, name, addr As String
only declares addr
as String
but all the others as Variant
in VBA you need to declare a type for every variable Dim des As String, name As String, addr As String
, also row counting variables need to be of type Long
as Excel has more rows that fit into Integer
.
Also the brackets you use here Application.SendKeys ("{TAB}")
are not doing what you expect them to do. It must be either:
Application.SendKeys "{TAB}" 'no Call and no `=` sign no brackets
or
Call Application.SendKeys("{TAB}")
Finally if your application does not react to the tab but to all other SendKeys
then this application is somehow interfering with SendKeys
(incompatible) or it is blocking something. Actually as you wrote the code it should work. I cannot reproduce your issue and I definitely see the tab being sent.