Solved

VBA to navigate web site

Posted on 2014-09-24
7
112 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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 46

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

832 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