Showing posts with label Login to Website using Excel VBA. Show all posts
Showing posts with label Login to Website using Excel VBA. Show all posts

Monday, October 14, 2013

How to Login to a HTTPS Website PopUp using Excel VBA

Control Login Popup from Excel VBA 

The new HTTPS popups cause lot of irritation to the developers who have coded for it before.


I have tried to circumvent it using SendKeys. Please have a look at the snippet below and share your views on it



 
     Set ie = CreateObject("InternetExplorer.Application.1")
            ie.Visible = True
            ie.navigate cURL
             
             Application.Wait (Now + TimeValue("0:00:10"))
            If ie.readyState = READYSTATE_LOADING Then
         
              Set objShellWindows = New ShellWindows

            Application.SendKeys "abcd"
            Application.SendKeys "{TAB}"
            Application.SendKeys "pwd123"
            Application.SendKeys "{TAB}"
            Application.SendKeys "{RETURN}"
           
            End If
             
        'Do While ie.Busy: DoEvents: Loop
          Set doc = ie.Document

Saturday, August 08, 2009

How to Login to Website Using VBA

Login to Google Account using VBA


Here is a simple code that will login to Google accounts with the provided user-name and password.



The program requires references to the following:

1 Microsoft Internet Controls
2. Microsoft HTML Object Library

Microsoft HTML Object LibraryMicrosoft HTML Object Library- VBA Reference

Microsoft Internet Controls - VBA Reference Microsoft Internet Controls - VBA Reference



The Internet control is used to browse the webpage and the HTML Objects are used to identify the username and password textboxes and submit the text using the control button.


Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Sub Login_2_Website()


Dim oHTML_Element As IHTMLElement
Dim sURL As String


On Error GoTo Err_Clear
sURL = "https://www.google.com/accounts/Login"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True

Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE

Set HTMLDoc = oBrowser.Document

HTMLDoc.all.Email.Value = "
sample@vbadud.com"
HTMLDoc.all.passwd.Value = "*****"

For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
Next


' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
If Err <> 0 Then
Debug.Assert Err = 0
Err.Clear
Resume Next
End If

End Sub






See Also : http://vbadud.blogspot.com/2008/05/google-search-using-vba.html
Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.