![]() |
Runtime error 91 on website login
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 |
Runtime error 91 on website login
Looks as though for some reason there is no "ipf" input element in the
document. Try adding some error checking to catch this. Eg: Set ipf = ie.document.all.Item("s10_") If ipf is nothing then Msgbox "Input 's10_' not found!" Exit sub Else ipf.Value = username End If Tim wrote in message ups.com... 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 |
All times are GMT +1. The time now is 10:14 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com