fahadurrehman
New Member
- Joined
- Sep 22, 2017
- Messages
- 1
Hi Experts,
I am trying very hard since last few weeks but not able to automate website login through VBA. Using below stated code. It opens URL but User_Name and Password fields never populated. I am using below pasted code taken from google help pages.
Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer
Sub MyGmail()
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
On Error GoTo Err_Clear
MyURL = "http://eecsaruh2how094/MMP2/"
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. ContentPlaceHolder1_txtUser.Value = "nsn-noc" 'ContentPlaceHolder1_txtUser is ID of user name
HTMLDoc.all.ContentPlaceHolder1_txtPass.Value = "Nokianoc" 'ContentPlaceHolder1_txtUser is ID of 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
I am trying very hard since last few weeks but not able to automate website login through VBA. Using below stated code. It opens URL but User_Name and Password fields never populated. I am using below pasted code taken from google help pages.
Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer
Sub MyGmail()
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
On Error GoTo Err_Clear
MyURL = "http://eecsaruh2how094/MMP2/"
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. ContentPlaceHolder1_txtUser.Value = "nsn-noc" 'ContentPlaceHolder1_txtUser is ID of user name
HTMLDoc.all.ContentPlaceHolder1_txtPass.Value = "Nokianoc" 'ContentPlaceHolder1_txtUser is ID of 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