Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code works on IE 6 but not IE 7

Status
Not open for further replies.

krieg313

Technical User
May 5, 2011
22
US
The Code below was made in access 2003 and tested on IE6 and it worked fine, but after testing it on ie7 it gives off errors such as Object variable not defined, or Subscript out of range

Sub Kick_Off_Log_In()

Const str_usr = "qcc04"
Const str_pw = "qc"
Dim username As MSHTML.IHTMLInputElement
Dim Password As MSHTML.IHTMLInputElement
Dim LogInBtn As MSHTML.IHTMLInputElement
Dim username1 As MSHTML.IHTMLInputElement
Dim Password1 As MSHTML.IHTMLInputElement
Dim LogInBtn1 As MSHTML.IHTMLInputElement


Set iekickoff = CreateObject("InternetExplorer.Application")
iekickoff.navigate "
While iekickoff.Busy
DoEvents
Wend

Set username = iekickoff.Document.all.Item("loginIdTextBox")
Set Password = iekickoff.Document.all.Item("passwordTextBox")
Set LogInBtn = iekickoff.Document.all.Item("logonButton")

username.Value = str_usr
Password.Value = str_pw
LogInBtn.Click

While iekickoff.Busy
DoEvents
Wend

Set ie = CreateObject("InternetExplorer.Application")
ie.navigate "
While ie.Busy
DoEvents
Wend

Set username1 = ie.Document.all.Item("loginIdTextBox")
Set Password1 = ie.Document.all.Item("passwordTextBox")
Set LogInBtn1 = ie.Document.all.Item("logonButton")

username1.Value = str_usr
Password1.Value = str_pw
LogInBtn1.Click

While ie.Busy
DoEvents
Wend

iekickoff.Visible = 1

End Sub


I suspect it has something to do with the

While Ie.Busy
Doevents
Endw
Thanks in advance.
 
I'd really appreciate a reply or at least redirect me to a helpful post.
 
>it gives off errors such as Object variable not defined, or Subscript out of range


It might help to help you if you told us which lines specific errors occurred on. It's like you've gone to a garage with a car and said "My car doesn't work. What's wrong with it?" We need more info.
 
How have you declared ie and iekickoff?

If at first you don't succeed, then sky diving wasn't meant for you!
 
Sorry about that, I should have been more specific.
The line that is giving me trouble is

username.Value = str_usr
Password.Value = str_pw
LogInBtn.Click

Run-Time Error "91"
Object variable or with block variable not set.

HTH
 
Well, it turns out IE7 didnt like me naming my Constants Username
and username1 because after i changed username1 to USRNM, everything was working as it should, i am curious to know why it didn't work before i changed the name.
hopefully someone answers~!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top