Solved

VBA to navigate web site

Posted on 2014-09-24
7
107 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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 45

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now