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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

navigating websites through VBA

Status
Not open for further replies.

dick606

Technical User
Mar 15, 2009
9
0
0
US
here is a snippet of my code:
Code:
set ie = createobject("internetexplorer.application")

ie.navigate me.website

while ie.busy
  do events
wend

ie.document.forms(me.formnumber).item("username") = me.username
ie.document.forms(me.formnumber).item("password") = me.password
ie.document.forms(me.formnumber).submit
as some may have guessed, i'm trying to automate a login from my database. the problem is, when i click the button on my form to run the ENTIRE code (which is obviously not all here, but it does work), sometimes it is successful and sometimes it is not.

as in, sometimes, i get some of the populations in the textboxes, and sometimes not. when i created a loop to go back through and check for errors in my code, sometimes it bugs at:
Code:
ie.document.forms(me.formnumber).item("username") = me.username
with the error of "object variable not set". This cannot be the case, as they are all set in the code. These errors are completely random, as to say that I can run this code 5 times and open up 5 different explorer windows, and the code may be successful the first, last or any other time in between. and I am not sure of the reason why this randomly debugs on ANY of the "populating" lines of code.
Code:
(e.g. - website textbox = one of my variables)
Anyone have any ideas on this?
 
dick606,
You need to check the [tt]readyState[/tt] of IE in addition to [tt]busy[/tt] to determine if a page is completely loaded.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
I'll experiment with it. thank you. that may be causing the problems as well? I had no idea..
 
You may also want to include an error handler that will loop back and attempt the logon again (personally, I would have it cycle thru about 5 attempts).

Travis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top