Hey guys!
I need to have my VBA macro enter the user name and pasword to login a website.
I have read a number of posts related to this topic, tried a number of different methods and still can't get it to work.
Can anyone have a look an tell me how I must have the macro?
Any help is appreciated. Thanks.
I need to have my VBA macro enter the user name and pasword to login a website.
I have read a number of posts related to this topic, tried a number of different methods and still can't get it to work.
Code:
Dim HTMLDoc As HTMLDocumentDim MyBrowser As InternetExplorer
Sub RepsolLogin()
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
MyURL = "https://login.repsol.com/es/Landing/AuthnPage?returnUrl=https://www.repsol.com/es_es/"
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.UserName.Value = "xxx@xxx.com" 'Enter your email id here
HTMLDoc.all.Password.Value = "xxxx" 'Enter your password here
For Each MyHTML_Element In HTMLDoc.getElementById("Iniciar sesión")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
Next
End Sub
Can anyone have a look an tell me how I must have the macro?
Any help is appreciated. Thanks.