Solved

VBA to navigate web site

Posted on 2014-09-24
7
114 Views
Last Modified: 2014-11-22
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
Comment
Question by:rrhandle8
  • 3
  • 2
7 Comments
 
LVL 12

Expert Comment

by:James Elliott
ID: 40342006
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
 

Author Comment

by:rrhandle8
ID: 40342058
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
 

Author Comment

by:rrhandle8
ID: 40342100
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Accepted Solution

by:
James Elliott earned 500 total points
ID: 40343448
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
 

Author Comment

by:rrhandle8
ID: 40343859
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
 
LVL 47

Expert Comment

by:Martin Liss
ID: 40459213
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question