Kumarcoolz
07-30-2013, 11:39 PM
I need your help guys, I wanted to login to my office website through Excel, i have amature idea on coding and i rely on google and forums alot. and no idea on HTML
Sub Test()
Const cURL = "https://intranet.quest-global.com/intranet/Logon.aspx?ReturnUrl=%2fintranet%2fQuEST-Global-Net.aspx"
Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputElement
Dim PasswordInputBox As HTMLInputElement
Dim SignInButton As HTMLInputButtonElement
Dim HTMLelement As IHTMLElement
Dim qt As QueryTable
Dim cUsername As String
Dim cPassword As String
cUsername = Sheet1.Cells(1, 2)
cPassword = Sheet1.Cells(2, 2)
Set IE = New InternetExplorer
IE.Visible = True
IE.Navigate cURL
Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Set doc = IE.Document
Set LoginForm = doc.forms(0)
Set UserNameInputBox = LoginForm.elements("p$lt$zoneLeft$Quest_LoginAD1$txtUserName")
UserNameInputBox.Value = cUsername
Set PasswordInputBox = LoginForm.elements("p$lt$zoneLeft$Quest_LoginAD1$txtPassword")
PasswordInputBox.Value = cPassword
' i was not able to automate the click on the Login button on this part
Set SignInButton = LoginForm.elements("p$lt$zoneLeft$Quest_LoginAD1$btnAuthenticate")
SignInButton.Click
Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
End Sub
I did manage to enter data to the username and password field but i was not able to execute the login button.
I dont have a idea on understanding HTML but when i did F12 on the Webpage, i found that
the login button is actually a image type with onclick option
<input name="p$lt$zoneLeft$Quest_LoginAD1$btnAuthenticate" id="p_lt_zoneLeft_Quest_LoginAD1_btnAuthenticate" onclick="return validateInputs();" type="image" src="Quest/Images/login-button-2.png" complete="complete"/>
I got this code from the link below:
post #5
http://www.mrexcel.com/forum/excel-questions/530303-visual-basic-applications-enter-login-password-website.html
It would be great if someone helps me with this :help
Sub Test()
Const cURL = "https://intranet.quest-global.com/intranet/Logon.aspx?ReturnUrl=%2fintranet%2fQuEST-Global-Net.aspx"
Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputElement
Dim PasswordInputBox As HTMLInputElement
Dim SignInButton As HTMLInputButtonElement
Dim HTMLelement As IHTMLElement
Dim qt As QueryTable
Dim cUsername As String
Dim cPassword As String
cUsername = Sheet1.Cells(1, 2)
cPassword = Sheet1.Cells(2, 2)
Set IE = New InternetExplorer
IE.Visible = True
IE.Navigate cURL
Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Set doc = IE.Document
Set LoginForm = doc.forms(0)
Set UserNameInputBox = LoginForm.elements("p$lt$zoneLeft$Quest_LoginAD1$txtUserName")
UserNameInputBox.Value = cUsername
Set PasswordInputBox = LoginForm.elements("p$lt$zoneLeft$Quest_LoginAD1$txtPassword")
PasswordInputBox.Value = cPassword
' i was not able to automate the click on the Login button on this part
Set SignInButton = LoginForm.elements("p$lt$zoneLeft$Quest_LoginAD1$btnAuthenticate")
SignInButton.Click
Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
End Sub
I did manage to enter data to the username and password field but i was not able to execute the login button.
I dont have a idea on understanding HTML but when i did F12 on the Webpage, i found that
the login button is actually a image type with onclick option
<input name="p$lt$zoneLeft$Quest_LoginAD1$btnAuthenticate" id="p_lt_zoneLeft_Quest_LoginAD1_btnAuthenticate" onclick="return validateInputs();" type="image" src="Quest/Images/login-button-2.png" complete="complete"/>
I got this code from the link below:
post #5
http://www.mrexcel.com/forum/excel-questions/530303-visual-basic-applications-enter-login-password-website.html
It would be great if someone helps me with this :help