PDA

View Full Version : Login into a website through Excel



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

stanleydgrom
08-03-2013, 04:51 AM
Kumarcoolz,

I have not used the product, but, you may want to check out autoit:
AutoIt - AutoItScript (http://autoitscript.com/autoit3)

AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.

It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys).

AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying “runtimes” required!

ZVI
08-04-2013, 06:02 PM
Try this:


Doc.All.p_lt_zoneLeft_Quest_LoginAD1_btnAuthenticate.Click