Plastikman
New Member
- Joined
- Apr 25, 2011
- Messages
- 9
Dear Excel experts!
I would like to automatically collect data from a password protected webpage but I can not find a proper way to do it. I manage to log in on the main page but then I can't collect chosen data. Any ideas?
My code so-far...
Many thanks
I would like to automatically collect data from a password protected webpage but I can not find a proper way to do it. I manage to log in on the main page but then I can't collect chosen data. Any ideas?
My code so-far...
Code:
Sub X11LogIn_Open()
[COLOR=#008000]'I didn't wrote "the login code". It is something I found earlier in a excel forum. Slightly re-coded though
[/COLOR]
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.Navigate "http://www.xperteleven.com/" [COLOR=#008000]'login (main)page[/COLOR]
[COLOR=#008000]'Check for good connection to web page loop![/COLOR]
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop
Application.Wait (Now + TimeValue("0:00:05"))
[COLOR=#008000]'Wait for window to open![/COLOR]
IE.Visible = True
[COLOR=#008000]'Send log-on information![/COLOR]
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "USERNAME", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "PASSWORD", True
SendKeys "{ENTER}", True
[COLOR=#008000]'Log in code ends here...[/COLOR]
[COLOR=#008000]
'...and web Query starts[/COLOR]
Application.Wait (Now + TimeValue("0:00:05"))
IE.Navigate "http://www.xperteleven.com/team.aspx?TeamID=1102399&dh=5" [COLOR=#008000]'<-- It is from this page I would like to recieve data![/COLOR]
Application.Wait (Now + TimeValue("0:00:05"))
Sheets("Query").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.xperteleven.com/team.aspx?TeamID=1102399&dh=5", Destination:= _
Range("$A$1"))
.Name = "team.aspx?TeamID=1102399&dh=5_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "11"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
Many thanks