Solved

VB to monitor Internet Explorer's progress Bar

Posted on 2008-10-23
5
634 Views
Last Modified: 2013-12-26
Hi,
I'm tring to automate entry into a  series of web pages using VBA

I'm having great difficulty getting my code to wait for the next screen to appear when a button is clicked.

I've tred both READYSTATE and .Busy and neither work

READYSTATE_COMPLETE  and Busy=false are set the instant the button is clicked
I think this may be because the buttons are firing javascript suncitons, not HTML links

I've tried hard-coding Waits into the code, but it isn't really adequate

I have noticed  though , when the buttons are clicked, in every case the Internet Explorer progress bar appears and more-or-less disappears then the update is complete.

Is there anyway in VB to monitor the value or state of the progress bar in an Internet Explorer object?

Thanks
0
Comment
Question by:greep
  • 2
5 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 22790710
Hi,

objIE.ReadyState or objIE.Busy really should work.....what version of IE, and what OS are you using?

Here's how I use that in VBS....

Regards,

Rob.
strURL = "http://www.experts-exchange.com"
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate "about:blank"
WaitForIE
objIE.Navigate strURL
WaitForIE
 
objIE.Document.form1.uname.Value = "username"
objIE.Document.form1.upassword.Value = "password"
objIE.Document.form1.submit
 
Set objIE = Nothing
MsgBox "Done"
 
Sub WaitForIE
	On Error Resume Next
	While objIE.ReadyState <> 4
		WScript.Sleep 100
	Wend
	While objIE.Busy = True
		WScript.Sleep 100
	Wend
	Err.Clear
	On Error GoTo 0
End Sub

Open in new window

0
 

Author Comment

by:greep
ID: 22794554
Hi Rob
it seems to work OK if I use .navigate
       (see first code snip)
But not if I use Sendkeys.        (see second snip)
My problem Is that the last part of the sequence  (GLTR + Enter)  triggers a Java Function that re-populates a fame with a set of inputs and buttons   I have no way of finding the source for this new set of controls, and they do not appear when I query the objIE page elements.
The only way I seem to be able to get to them is to use Sendkeys to push the cursor to the relevent element.
But when I send "Enter"  .readystate and .busy are instanstly set and the subsequent code does not input correctly
Any suggestions gratefuly received
Regards
Mike
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Visible = True
    objIE.Navigate "http://edauat.company.net/system/"
    WaitForIE
    objIE.Document.all("USERNAME").Value = uid
    objIE.Document.all("PASSWORD").Value = pw
    objIE.Navigate "javascript:submitForm();"
    WaitForIE
    objIE.Document.selectRole.role.Value = 1000004
    objIE.Navigate "javascript:selectRole();"
    WaitForIE
    objIE.Document.all("quickJump").Value = "GLTR"
    objIE.Navigate "javascript:SubmitQuickJump();"
    WaitForIE
--------------------------------------------------------
    objIE.Navigate "http://edauat.company.net/system/"
    objIE.Visible = True
    WaitForIE
    AppActivate objIE
    sendkeys "J960066{TAB}33kingko~", True
    WaitForIE
    AppActivate objIE
    sendkeys "{DOWN 7}~", True
    WaitForIE
    AppActivate objIE
    sendkeys "{TAB 5}GLTR~", True
    WaitForIE

Open in new window

0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 22805611
Hmmm, if you knew the name of the JavaScript function (which you might be able see from the Source, or from the Status Bar as you hover over the link), you can try to execute it using this:

objIE.document.frames.execScript "window.document.JavaScriptFunctionName();", "JavaScript"

Regards,

Rob.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

821 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