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:
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.
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
Thanks for the help.