Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 145
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A spreadsheet template for website login details backlash Excel Discussion (Misc queries) 0 February 27th 09 07:38 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Interior class error/runtime error 1004 David Goodall Excel Programming 1 October 24th 04 10:16 PM
Making a auto website login script TMO[_5_] Excel Programming 0 February 7th 04 08:50 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 04:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"