Input Text Into Html Input Box Using Vba
I am trying to input a value into a from on an internet explorer page using VBA. I have seen similar posts but can't seem to pinpoint my problem. I am somewhat fluent with VBA bu
Solution 1:
As sid mentioned, you have an extra "=" sign.
Replace
SetObjCollection= ie.Document.getElementsByName("user_numbers.1.number_1").Value = "123"
with
ie.Document.getElementsByName("user_numbers.1.number_1")(0).Value = "123"
This is just off my head and not tested code. If this doesn't work replace (0)
in the above code with (1)
.
If there is no other element on the page with the same name then this will work.
Otherwise replace (0)
in the above statement with appropriate ordinal position.
Solution 2:
How about finding the ID everytime like this
my_var = ie.doc.body.innerhtml
pos_1 = instr(1, my_var, "user_numbers.1.number_1", vbTextCompare)
pos_2 = InStrRev(my_var, "id", pos_1, vbTextCompare)
pos_3 = instr(pos_2, my_var, "name", vbTextCompare)
my_id = mid(my_var, 3+pos_2, (-1+pos_3) - (3+pos_2)
now try
ie.Document.getElementById(my_id).Value = "123"
I can't get access to your url, so you might have to tweak the numbers added and subtracted in the "mid" function
Post a Comment for "Input Text Into Html Input Box Using Vba"