A
ajbarilla
I have code that copies data from a website into excel. Since its a
login site, I can get a webquery to work correct. The following code
works about 90% of the time but 10% of the time I get an "object
variable or with block variable not set - runtime error 91" error on
ipf.value=username line. Im not sure why i am getting this error.
Any help would be appreciated.
Dim username As String
Dim password As String
Dim ie as object
Set ie = CreateObject("internetexplorer.application")
With ie
.Visible = True
.Navigate "https://mywebsite"
Do Until Not .busy
DoEvents
Loop
username = ActiveSheet.Range("z1").Value
Debug.Print username
password = ActiveSheet.Range("z2").Value
Debug.Print password
Set ipf = ie.document.all.Item("s10_")
ipf.Value = username <--------ERROR HERE
Set ipf = ie.document.all.Item("s12_")
ipf.Value = password
Set ipf = ie.document.all.Item("s16_")
ipf.Click
Do Until Not .busy
DoEvents
Loop
End With
login site, I can get a webquery to work correct. The following code
works about 90% of the time but 10% of the time I get an "object
variable or with block variable not set - runtime error 91" error on
ipf.value=username line. Im not sure why i am getting this error.
Any help would be appreciated.
Dim username As String
Dim password As String
Dim ie as object
Set ie = CreateObject("internetexplorer.application")
With ie
.Visible = True
.Navigate "https://mywebsite"
Do Until Not .busy
DoEvents
Loop
username = ActiveSheet.Range("z1").Value
Debug.Print username
password = ActiveSheet.Range("z2").Value
Debug.Print password
Set ipf = ie.document.all.Item("s10_")
ipf.Value = username <--------ERROR HERE
Set ipf = ie.document.all.Item("s12_")
ipf.Value = password
Set ipf = ie.document.all.Item("s16_")
ipf.Click
Do Until Not .busy
DoEvents
Loop
End With