Hi,
I have been updating a simple access code I use in VBA (below)
<tbody>
</tbody>
<tbody>
</tbody>
This works to a point as i am accessing newer web pages and it is not placing the PIN and Password i have in the Macro, so i am trying to use this newer version, but i am getting the same result no PIN or Password.
<tbody>
</tbody>
I need help to get this solved because in the new pages, the ID is "pf.username" so i can't use the first code effectively.
Any help would be really appreciated.
I have been updating a simple access code I use in VBA (below)
Dim HTMLDoc As HTMLDocument |
Dim MyBrowser As InternetExplorer |
Sub MyReece() |
<tbody>
</tbody>
Dim MyHTML_Element As IHTMLElement |
Dim MyURL As String |
On Error GoTo Err_Clear |
MyURL = "https://www.xxx.com" |
Set MyBrowser = New InternetExplorer |
MyBrowser.Silent = True |
MyBrowser.navigate MyURL |
MyBrowser.Visible = True |
Do |
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE |
Set HTMLDoc = MyBrowser.document |
HTMLDoc.all.Email.Value = "Infousername" |
HTMLDoc.all.password.Value = "Info password" |
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input") |
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For |
Next |
Err_Clear: |
If Err <> 0 Then |
Err.Clear |
Resume Next |
End If |
End Sub |
<tbody>
</tbody>
This works to a point as i am accessing newer web pages and it is not placing the PIN and Password i have in the Macro, so i am trying to use this newer version, but i am getting the same result no PIN or Password.
Sub Test_LoginXXX() |
LoginReece "kEmail", "kPassword" |
End Sub |
' Add references in Tools > References for: |
' Microsoft HTML Object Library |
' Microsoft Forms 2.0 Object Library |
' Microsoft Internet Controls |
Sub LoginXXX(email As String, password As String) |
Const strURL_c As String = "https://www.xxx.com" |
Dim url As String |
Dim objIE As SHDocVw.InternetExplorer |
Dim ieDoc As MSHTML.HTMLDocument |
Dim tbxPwdFld As MSHTML.HTMLInputElement |
Dim tbxUsrFld As MSHTML.HTMLInputElement |
Dim btnSubmit As MSHTML.HTMLInputElement |
Excel.Application.Cursor = xlWait |
On Error GoTo Err_Hnd |
'Create Internet Explorer Object |
Set objIE = New SHDocVw.InternetExplorer |
'Navigate the URL |
objIE.navigate strURL_c |
objIE.Visible = True |
'Wait for page to load |
'https://msdn.microsoft.com/en-us/library/ms534361(v=vs.85).aspx |
Do Until objIE.readyState = READYSTATE_COMPLETE: Loop |
'Do: Loop Until objIE.readyState = READYSTATE_COMPLETE |
Set ieDoc = objIE.document |
Application.Wait Now + TimeValue("00:00:05") |
ieDoc.getElementsByName("email").Item(0).Value = PIN |
ieDoc.getElementById("password").Value = Password |
ieDoc.getElementsByClassName("btn btn-primary btn-med ladda-button").Item(0).Click |
Err_Hnd: '(Fail gracefully) |
objIE.Visible = True |
On Error GoTo 0 |
Excel.Application.Cursor = xlDefault |
End Sub |
<tbody>
</tbody>
I need help to get this solved because in the new pages, the ID is "pf.username" so i can't use the first code effectively.
Any help would be really appreciated.
Last edited: