edrz01
asked on
Embedded Web Browser login script problem
I have an embedded web browser in a form and it is designed to automatically fill in the username and password and submit. When I step through the code it works great but when I try to run it from either a form load or a click it fails saying incorrect login infortmation. This has me stumped. I have put in delay loops, etc to no avail.
Any ideas?
Any ideas?
ASKER
Option Compare Database
Private Sub Command18_Click()
Me.WebBrowser7.Navigate "http://someserver.com/HPOV_Reports/OVIS_USERNAMEGOESHERE/All/Data.gif"
End Sub
Function Logon()
SysCmd SYSCMD_SETSTATUS, "Opening Internet Explorer"
On Error Resume Next
Set Ie = CreateObject("InternetExpl orer.Appli cation")
If Err.Number <> 0 Then
MsgBox "Unable to open Internet Explorer" & Chr(13) _
& "Open it and navigate to Freeclaims.com manually."
DoCmd.Hourglass False
SysCmd SYSCMD_CLEARSTATUS
Exit Function
End If
WebBrowser1.Visible = True
SysCmd SYSCMD_SETSTATUS, "Loading login page"
With WebBrowser1
.Navigate "http://someserver.com/hpov_reports/iops.htm"
.Visible = True
End With
For pauseit = 1 To 100
Next pauseit
StartTime = Now()
If DateDiff("s", StartTime, Now) > 120 Then
WebBrowser1.Visible = False
MsgBox "Unable to navigate to 'http://someserver.com/hpov_reports/iops.htm" _
& Chr(13) & "The site may not be active at this time" _
& Chr(13) & "Try to navigate there manually."
WebBrowser1.Visible = True
WebBrowser1.Value = Nothing
'Set WebBrowser1 = Nothing
DoCmd.Hourglass False
SysCmd SYSCMD_CLEARSTATUS
Exit Function
End If
Err.Clear
WebBrowser1.Document.login .focus
WebBrowser1.Document.login ("customer ").Value = "USERNAMEGOESHERE"
WebBrowser1.Document.login ("Pswd").V alue = "^P@ssW0rd!"
WebBrowser1.Document.login .Action = "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?content=login&"
WebBrowser1.Document.login .focus
WebBrowser1.Document.login ("customer ").Value = "USERNAMEGOESHERE"
Password = "^P@ssW0rd!"
WebBrowser1.Document.login ("Pswd").V alue = Password
For pauseit = 1 To 100
Next pauseit
WebBrowser1.Document.Forms ("LOGIN"). submit.foc us
'Ie.Document.LOGIN.submit
' MsgBox (Err.Number)
For pauseit = 1 To 100
Next pauseit
If Err.Number = 424 Then
Err.Clear
ElseIf Err.Number <> 0 Then
WebBrowser1.Visible = False
WebBrowser1.Visible = True
DoCmd.Hourglass False
SysCmd SYSCMD_CLEARSTATUS
Exit Function
End If
For pauseit = 1 To 100
Next pauseit
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=availability&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
End Function
Private Sub Frame0_Click()
Me.WebBrowser1.Visible = True
Logon
Select Case Me.Frame0.Value
Case 1
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=availability&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
Case 2
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=response&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
Case 3
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=violations&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
Case 4
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=trend&customer=USERNAMEGOESHERE&metric=AVAILABILITY&probeType=All+Services&serviceGroup=All+Service+Groups"
Case 5
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=snapshot&customer=USERNAMEGOESHERE&metric=AVAILABILITY&probeType=All+Services&serviceGroup=All+Service+Groups"
End Select
End Sub
Private Sub Command18_Click()
Me.WebBrowser7.Navigate "http://someserver.com/HPOV_Reports/OVIS_USERNAMEGOESHERE/All/Data.gif"
End Sub
Function Logon()
SysCmd SYSCMD_SETSTATUS, "Opening Internet Explorer"
On Error Resume Next
Set Ie = CreateObject("InternetExpl
If Err.Number <> 0 Then
MsgBox "Unable to open Internet Explorer" & Chr(13) _
& "Open it and navigate to Freeclaims.com manually."
DoCmd.Hourglass False
SysCmd SYSCMD_CLEARSTATUS
Exit Function
End If
WebBrowser1.Visible = True
SysCmd SYSCMD_SETSTATUS, "Loading login page"
With WebBrowser1
.Navigate "http://someserver.com/hpov_reports/iops.htm"
.Visible = True
End With
For pauseit = 1 To 100
Next pauseit
StartTime = Now()
If DateDiff("s", StartTime, Now) > 120 Then
WebBrowser1.Visible = False
MsgBox "Unable to navigate to 'http://someserver.com/hpov_reports/iops.htm" _
& Chr(13) & "The site may not be active at this time" _
& Chr(13) & "Try to navigate there manually."
WebBrowser1.Visible = True
WebBrowser1.Value = Nothing
'Set WebBrowser1 = Nothing
DoCmd.Hourglass False
SysCmd SYSCMD_CLEARSTATUS
Exit Function
End If
Err.Clear
WebBrowser1.Document.login
WebBrowser1.Document.login
WebBrowser1.Document.login
WebBrowser1.Document.login
WebBrowser1.Document.login
WebBrowser1.Document.login
Password = "^P@ssW0rd!"
WebBrowser1.Document.login
For pauseit = 1 To 100
Next pauseit
WebBrowser1.Document.Forms
'Ie.Document.LOGIN.submit
' MsgBox (Err.Number)
For pauseit = 1 To 100
Next pauseit
If Err.Number = 424 Then
Err.Clear
ElseIf Err.Number <> 0 Then
WebBrowser1.Visible = False
WebBrowser1.Visible = True
DoCmd.Hourglass False
SysCmd SYSCMD_CLEARSTATUS
Exit Function
End If
For pauseit = 1 To 100
Next pauseit
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=availability&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
End Function
Private Sub Frame0_Click()
Me.WebBrowser1.Visible = True
Logon
Select Case Me.Frame0.Value
Case 1
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=availability&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
Case 2
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=response&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
Case 3
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=violations&customer=USERNAMEGOESHERE&startTime=-1&probeType=All+Services&endTime=-1"
Case 4
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=trend&customer=USERNAMEGOESHERE&metric=AVAILABILITY&probeType=All+Services&serviceGroup=All+Service+Groups"
Case 5
Me.WebBrowser1.Navigate "http://someserver.com/HPOV_IOPS/cgi-bin/RepIOps.exe?utf8=1&content=snapshot&customer=USERNAMEGOESHERE&metric=AVAILABILITY&probeType=All+Services&serviceGroup=All+Service+Groups"
End Select
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Andy, looks like a syntax problem with the DoEvents(). It errors saying it is expecting an '='.
Sorry,
just type DoEvents and then <ENTER>
just type DoEvents and then <ENTER>
just post your code