?
Solved

VBA to navigate web site

Posted on 2014-09-24
7
Medium Priority
?
117 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 12

Accepted Solution

by:
James Elliott earned 2000 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 49

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
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 how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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