Login to website through Excel web session

excelsupernerd

New Member
Joined
Jul 28, 2010
Messages
14
I have to pull several Web Queries in a workbook, all come from a website that requires login before I can access the urls.

Here is my code I made to login to the website through Internet Explorer:
Code:
Sub connectToScantron()
   Dim objIE As Object
   Dim objCollection As Object
   Dim objElement As Object
   
   Set objIE = CreateObject("InternetExplorer.Application")
   
   If Not objIE Is Nothing Then
    
      With objIE
         .Visible = True
         .navigate "https://admin.achievementseries.com/!/login.ssp"
         Do While .Busy: DoEvents: Loop
         Do While .readyState <> 4: DoEvents: Loop
         
         Set objCollection = objIE.document.getElementsByTagName("input")
         
         i = 0
         While i < objCollection.Length
            If objCollection(i).Name = "Username" Then
               objCollection(i).Value = InputBox("Please enter username:")
            ElseIf objCollection(i).Name = "Password" Then
               objCollection(i).Value = InputBox("Please enter password:")
            ElseIf objCollection(i).Type = "submit" And _
               objCollection(i).Name = "" Then
               Set objElement = objCollection(i)
            End If
            i = i + 1
         Wend
         objElement.Click    ' click button to search
      
      End With
  
  End If
  
  Set frmHTML = Nothing
  Set docHTML = Nothing
  Set objIE = Nothing
   
End Sub
The problem is that in order for Excel to pull a web query, the login needs to happen inside of Excel's session, not Internet Explorer's. What object can I use to access web site's and authenticate a web session through Excel so that I can pull Web Queries through Excel without opening a new Web Query, navigating to the login page, logging in, then closing the extra Web Query?

Thanks for the help.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,215,348
Messages
6,124,425
Members
449,157
Latest member
mytux

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top