Hello all
My goal is to download my data from a web site that requires both a login and a password.
My problem is that the login and password fields are on separate websites (login is on URL #1 while the password field is on URL #2). Clicking the submit button on URL #1 redirects the Browser to URL #2.
My specific glitch is that the Excel VBA code (see below) stalls with the blinking cursor in the empty password field on URL #2.
I believe my problem is related to the fact that my code is associated with URL #1 and will not run when the Browser is redirected to URL #2.
Over the last 3 days I’ve extensively and exhaustively searched the www for help on this issue without success.
My skill level in VBA and website data retrieval is poor to modest so any help on this issue is appreciated.
BobWald
My goal is to download my data from a web site that requires both a login and a password.
My problem is that the login and password fields are on separate websites (login is on URL #1 while the password field is on URL #2). Clicking the submit button on URL #1 redirects the Browser to URL #2.
My specific glitch is that the Excel VBA code (see below) stalls with the blinking cursor in the empty password field on URL #2.
I believe my problem is related to the fact that my code is associated with URL #1 and will not run when the Browser is redirected to URL #2.
Over the last 3 days I’ve extensively and exhaustively searched the www for help on this issue without success.
My skill level in VBA and website data retrieval is poor to modest so any help on this issue is appreciated.
BobWald
Code:
Option Explicit
Public Sub CU_Login_Website()
Dim oBrowser As InternetExplorer
Dim HTMLDoc As HTMLDocument
Dim oHTML_Element As IHTMLElement
Dim sURL As String
On Error GoTo Err_Clear
sURL = "https://www.URL #1"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True
Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.Document
HTMLDoc.all.Login.Value = "########"
HTMLDoc.all.Password.Value = "aaaaaaaaa"
For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
Next
' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
If Err <> 0 Then
'Debug.Assert Err = 0
Err.Clear
Resume Next
End If
End Sub