View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Sharad Sharad is offline
external usenet poster
 
Posts: 123
Default Web browser question

There is no any direct way to find out if IE has generated a message box
(I am talking about Reference to MS Internet Control).

However, if you are launching IE with a URL first time, if you give
command to GoForward, it will normall generate error "Unspecified
error", if no any dialogue box is active in IE.
If a dialogue box is active in IE, then on GoForward, it gives another
error "resource is in use."

Using this, it is possible to determine if a IE has generated a dialogue
box.
Below is a sample code (Reference to MS Internet Control)
In the below code I allow 10 seconds before giving the GoForard command
and checking what error it has generated. If your site takes longer you
can adjust the number of seconds.

You can check the below code by purposefully giving wrong password.

Regards
Sharad
Sub Rediculous()
Dim IE As InternetExplorer, nCount As Long
Set IE = New InternetExplorer
IE.Navigate "Your website url"
'your code for username/pwd but give WRONG PWD to test
IE.Visible = True
'below I allow 10 seconds to load
'you can change the seconds as per your site speed
nCount = Timer
Do While Timer < nCount + 10
DoEvents
Loop

On Error Resume Next
IE.GoForward
If InStr(1, Err.Description, "resource is in use", vbTextCompare)
0 Then
'Now this means a dialog box is active in IE
AppActivate IE
'activate IE which by default activates the dailogue window
SendKeys "{ENTER}", True
' your further code to send username and pwd
End If
On Error GoTo 0
'Further code if no any dialogue box is active in IE
End Sub





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!