vendredi 22 mars 2019

Excel VBA , fill internet form, each form s different URL

I want to fill a form in internet, each form has it's own url , it saved in excel cell and all the data for this particular form in the same raw , so i want to run a loop single loop for entering data , it went nice for only the first raw , when it go to next i , gave me error 91 , for the

IE.Navigate (url_name) so don't know how to sit this as variable : i need help ASAP

this is the code

Sub FileInternetForm()

Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")

'create new instance of IE. use reference to return current open IE if

'you want to use open IE window. Easiest way I know of is via title ba

Dim i As Integer

For i = 1 To 100

'''Go to page

Dim url_name As String

url_name = ActiveSheet.Cells(i, 1)



If url_name = "" Then Exit Sub



''With url_name

IE.Navigate (url_name)

'go to web page listed inside quotes

IE.Visible = True



While IE.busy

DoEvents 'wait until IE is done loading page.

Wend

''End With



'''''' start





Set tbcno = IE.document.getElementById("tbcno")

tbcno.Value = ActiveSheet.Cells(i, 2)



Set Name = IE.document.getElementById("name")

Name.Value = ActiveSheet.Cells(i, 3)



Set Email = IE.document.getElementById("email")

Email.Value = ActiveSheet.Cells(i, 4)



Set mobile = IE.document.getElementById("mobile")

mobile.Value = ActiveSheet.Cells(i, 5)



Set gender = IE.document.getElementById("gender")

gender.Value = ActiveSheet.Cells(i, 6)



Set licenseno = IE.document.getElementById("licenseno")

licenseno.Value = ActiveSheet.Cells(i, 7)



Set girno = IE.document.getElementById("girno")

girno.Value = ActiveSheet.Cells(i, 8)



Set panno = IE.document.getElementById("panno")

panno.Value = ActiveSheet.Cells(i, 9)



Set haddress = IE.document.getElementById("haddress")

haddress.Value = ActiveSheet.Cells(i, 10)



Set hcity = IE.document.getElementById("hcity")

hcity.Value = ActiveSheet.Cells(i, 11)



Set hpin = IE.document.getElementById("hpin")

hpin.Value = ActiveSheet.Cells(i, 12)



Set hstate = IE.document.getElementById("hstate")

hstate.Value = ActiveSheet.Cells(i, 13)



Set oaddress = IE.document.getElementById("oaddress")

oaddress.Value = ActiveSheet.Cells(i, 14)



Set ocity = IE.document.getElementById("ocity")

ocity.Value = ActiveSheet.Cells(i, 15)



Set opin = IE.document.getElementById("opin")

opin.Value = ActiveSheet.Cells(i, 16)



Set lal = IE.document.getElementById("lal")

lal.Value = ActiveSheet.Cells(i, 17)



Set mrnno = IE.document.getElementById("mrnno")

mrnno.Value = ActiveSheet.Cells(i, 18)



Set af = IE.document.getElementById("af")

af.Value = ActiveSheet.Cells(i, 19)



Set nri = IE.document.getElementById("nri")

nri.Value = ActiveSheet.Cells(i, 20)



Set cp = IE.document.getElementById("cp")

cp.Value = ActiveSheet.Cells(i, 21)



'Click Button '



IE.document.getElementsByClassName("btn btn-info btn-fill")(0).Click

''Close Ie

IE.Quit

Set IE = Nothing

Next i

End Sub




Aucun commentaire:

Enregistrer un commentaire