+ Reply to Thread
Results 1 to 2 of 2

Excel VBA to login to a secured website

  1. #1
    Registered User
    Join Date
    08-23-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    1

    Thumbs up Excel VBA to login to a secured website

    Hi guys, I need advice for VBA on how to login to a secured website.

    The website is "https://www.creditbureau.com.sg/cgi/main"

    I read some discussions on how to login to simple websites where username and password fields can be access using the Input_Text box's name and then append .value = "username", so on for password.

    What do I have to code in VBA to access a secured site as mentioned above, when a login box appears?

    *Assume that
    Username is Jf18
    Password is Pass99

    ======
    I did something like this below. As you see, the website requests for username and password in a windows pop up form. How do I access that ?

    -Start Code-

    Dim HTMLDoc As HTMLDocument
    Dim myBrowser As InternetExplorer


    Dim iHTML_Element As IHTMLElement
    Dim sURL As String
    Sub SecuredSiteAccess()


    On Error GoTo Err_Clear
    sURL = "https://www.creditbureau.com.sg/cgi/main"
    Set myBrowser = New InternetExplorer
    myBrowser.Silent = True
    myBrowser.timeout = 60
    myBrowser.navigate sURL
    myBrowser.Visible = True

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

    Set HTMLDoc = myBrowser.document

    'Pseudo Password used
    IE.document.all("UserNameControl").Value = "Jf18"
    IE.document.all("PasswordControl").Value = "Pass99"
    IE.document.all("Submit Button").Click


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

    -End Code-

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Excel VBA to login to a secured website

    Hello Jds3579 and welcome to the forum.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1