+ Reply to Thread
Results 1 to 4 of 4

Using vba to login to a secured website

Hybrid View

  1. #1
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Using vba to login to a secured website

    My goal: To obtain a vba code that would log me in to this website upon running the macro, pull up and save the reports I need, and logout.
    Website: https://clearecd1.cpicentral.com/Default.aspx

    I am have no knowledge on servers, proxy servers, html coding, how to read it, write it, or how to find the box names with in the source code either. I only know those terms from reading other threads in my attempt to understand what their code was doing but it is a bit more complicated than I thought. I can get you any source code you need after the login page or screen shots so you can see exactly what I do to pull up the reports..
    Last edited by Jack7774; 03-18-2013 at 03:49 PM.

  2. #2
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: Using vba to login to a secured website

    Here is what I have but the screen acts as if I didn't enter anything, even when I click the cell to manually type it in instead of me having to erase what was typed by the macro it acts as if nothing was there to begin with even though i can see it before i click the text box. I am not sure if i am having problems because its a secure server. The macro works and does what its suppose to do but the server doesn't recognize what is put in the text boxes for some reason. Any thoughts?

    Private Sub Autologin()
         
        Dim ie As Object
         
        Set ie = CreateObject("InternetExplorer.Application")
         
        ie.navigate "https://clearecd1.cpicentral.com/Default.aspx"
        ie.Visible = True
        
        Do While ie.Busy And Not ie.readyState = 4
            DoEvents
        Loop
         
        DoEvents
         
        ie.document.all.Item("ctl00_MainContent_tbLoginCompanyID_text").Value = Sheets("Sheet1").Range("J1")
        ie.document.all.Item("ctl00_MainContent_tbLoginUsername_text").Value = Sheets("Sheet1").Range("J2")
        ie.document.all.Item("ctl00_MainContent_tbLoginPassword_text").Value = Sheets("Sheet1").Range("J3")
        ie.document.all.Item("ctl00$Maincontent$btnLoginUser").Click
         
    End Sub

  3. #3
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Using vba to login to a secured website

    Hi,

    You need to change :

     ie.document.all.Item("ctl00_MainContent_tbLoginCompanyID_text").Value = Sheets("Sheet1").Range("J1")
        ie.document.all.Item("ctl00_MainContent_tbLoginUsername_text").Value = Sheets("Sheet1").Range("J2")
        ie.document.all.Item("ctl00_MainContent_tbLoginPassword_text").Value = Sheets("Sheet1").Range("J3")
        ie.document.all.Item("ctl00$Maincontent$btnLoginUser").Click
    To

    ie.document.getElementById("ctl00_MainContent_tbLoginCompanyID_text").Value = Sheets("Sheet1").Range("J1")
        ie.document.getElementById("ctl00_MainContent_tbLoginUsername_text").Value = Sheets("Sheet1").Range("J2")
        ie.document.getElementById("ctl00_MainContent_tbLoginPassword_text").Value = Sheets("Sheet1").Range("J3")
        ie.document.getElementById("ctl00$Maincontent$btnLoginUser").Click
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  4. #4
    Forum Contributor Jack7774's Avatar
    Join Date
    08-31-2012
    Location
    Georgia, US
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: Using vba to login to a secured website

    I corrected it but its still does the same thing. It does type the data into the text boxes but it still asked for me to put in the data and when i click the text box to correct or edit the data that was put in the text box by the macro it disappears as if the data was never there even though i could see it before i clicked it.

    Private Sub Autologin()
         
        Dim ie As Object
         
        Set ie = CreateObject("InternetExplorer.Application")
         
        ie.navigate "https://clearecd1.cpicentral.com/Default.aspx"
        ie.Visible = True
        
        Do While ie.Busy And Not ie.readyState = 4
            DoEvents
        Loop
         
        DoEvents
         
        ie.document.getElementById("ctl00_MainContent_tbLoginCompanyID_text").Value = Sheets("Sheet1").Range("J1")
        ie.document.getElementById("ctl00_MainContent_tbLoginUsername_text").Value = Sheets("Sheet1").Range("J2")
        ie.document.getElementById("ctl00_MainContent_tbLoginPassword_text").Value = Sheets("Sheet1").Range("J3")
        ie.document.getElementById("ctl00$Maincontent$btnLoginUser").Click
        
    End Sub

+ 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