Good day,
I'm tasked to develop an application that opens a web page, completes some fields to log on and then issues a crlf to send it on its way.
Here's the code
Public Sub LoginIntoSite(ByRef wbBrowser As SHDocVw.InternetExplorer)
Dim HTMLDoc As mshtml.HTMLDocument
Dim HTMLDoc2 As mshtml.HTMLDocument
Do
Loop Until Not wbBrowser.Busy
HTMLDoc = wbBrowser.Document
Dim iHTMLCol As IHTMLElementCollection
Dim iHTMLEle As IHTMLElement
Dim str As String
iHTMLCol = HTMLDoc.getElementsByTagName("input")
' Type the user name in the username text box
For Each iHTMLEle In iHTMLCol
If Not iHTMLEle.getAttribute("name") Is Nothing Then
str = iHTMLEle.getAttribute("name").ToString
If str = "j_username" Then
iHTMLEle.setAttribute("value", "admin")
Exit For
End If
End If
Next
' Type the password in the password text box
For Each iHTMLEle In iHTMLCol
If Not iHTMLEle.getAttribute("name") Is Nothing Then
str = iHTMLEle.getAttribute("name").ToString
If str = "j_password" Then
iHTMLEle.setAttribute("value", "2)##SomePassword##")
Exit For
End If
End If
Next
So far so good if in weren't for the fact that it only runs when I step through the code manually. It would seem I need some mechanism to get the code to wait until it's safe to proceed.
The main problem I have is that after the password has been written to the correct field I need to pass an "Enter" or vbcrlf to submit the page. (The submit button is disabled, and the following code does not invoke any kind of a reaction )
For Each iHTMLEle In iHTMLCol
If Not iHTMLEle.getAttribute("name") Is Nothing Then
str = iHTMLEle.getAttribute("name").ToString
If str = "loginButton" Then
iHTMLEle.setAttribute("Enabled", True)
iHTMLEle.click()
Exit For
End If
End If
Next
Any help will be greatly appreciated!!!
Thanks