• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 131
  • Last Modified:

VBA to navigate web site

I have a VBA application that automates the placement of orders on a web site.  To do so, I must fill-in a form, then go to the next page, click come buttons, go to the next page......

The code works, but not all the time. When I navigate to the next page, I am using DoEvents to wait for the page to load.

            Do While ieApp.Busy: DoEvents: Loop
            Do Until ieApp.READYSTATE = READYSTATE_COMPLETE: DoEvents: Loop

Sometimes the loop ends, but the next I was waiting to load did not load.

Any ideas?
0
rrhandle8
Asked:
rrhandle8
  • 3
  • 2
1 Solution
 
James ElliottManaging DirectorCommented:
Are you saying that sometimes your webpage never loads and so the Do Until...Loop gets iterates indefinitely?

If so, you could implement a timeout feature in both loops.

Please confirm first that this is the issue though as it's not entirely clear from your question.
0
 
rrhandle8Author Commented:
James,  The loop finishes, the code attempts to access a element on the next page, but the browser is still showing the last page so I get an error message and the code stops.
0
 
rrhandle8Author Commented:
I should have added that I am in the process of building this app, I am show I.E. (visible=true), and am running and stopping it all day long.  Possible that I.E. is just getting confused from all me testing?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
James ElliottManaging DirectorCommented:
I'm having a similar problem at the moment, and the proper way to deal with the problem is to use the DocumentComplete event. Until I figure out how to do that in the best way, I've been adding some hard-coded pauses in spots where I know I'm having refresh-timing problems in my code.

Something like this:

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

While IE.Busy Or IE.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend: Sleep 2500

Open in new window

0
 
rrhandle8Author Commented:
Hi james,  I do have started using pause with the application.wait function.  3 seconds is working for me.  I will try bringing that down to 2 or 1.
0
 
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now