Gandalf the Grey
New Member
- Joined
- Apr 11, 2013
- Messages
- 11
I am trying to import data from a URL. My code works for XML, but not for the data in this URL. I can copy and paste the data into a spreadsheet, but don't know how to make the code work. Some one please help a lost soul in the wilderness...
ActiveWorkbook.Xml doesn't work, what does?
URL of interest: Einstein@Home Team stats for XtremeSystems
Current code:
Public Sub CapTeamStats()
Dim lgRow As Long 'Row Index
Dim lgTRow As Long 'Row Index
Dim boSvWarn As Boolean 'Save Application Warning Value
Const coXTbl As String = "There are more active members than lastweek Members table allows" & _
vbNewLine & vbNewLine & "increase the size and rerun!"
'/*---------------------------------*/
'/* Declare Team Capture URL */
'/*---------------------------------*/
Const coTSURL As String = "http://stats.kwsn.net/team.php?proj=einstein&teamid=6105"
Worksheets("WCG").Activate 'Set Active Sheet
'/*---------------------*/
'/* Clear Capture Sheet */
'/*---------------------*/
Cells.Select 'Select Entire Sheet
Selection.ClearContents 'Clear Contents
Cells(1, 1).Select 'Select First Cell in Active Sheet
boSvWarn = Application.DisplayAlerts 'Save Warning Setting
Application.DisplayAlerts = False 'Suppress Warnings
ActiveWorkbook.XmlImport URL:=coTSURL, ImportMap:=Nothing, _
Overwrite:=True, Destination:=Range("$A$1") 'Import XML File
Application.DisplayAlerts = boSvWarn 'Restore Warning Setting
lgRow = 2 'Set Starting Row
Do While Cells(lgRow, 15).Value <> vbNullString
lgTRow = lgRow + 4
If Left(Sheets("thisweek").Cells(lgTRow, 2).Value, 11) = "Team Totals" Then
MsgBox coXTbl, vbOKOnly, "Error - Active Member Space" 'Notify User
Exit Sub
End If
Sheets("thisweek").Cells(lgTRow, 2).Value = Cells(lgRow, 4).Value 'Member Name
Sheets("thisweek").Cells(lgTRow, 4).Value = Cells(lgRow, 7).Value 'Total Credits
Sheets("thisweek").Cells(lgTRow, 7).Value = Cells(lgRow, 8).Value 'Average credits
lgRow = lgRow + 1
Loop
lgTRow = lgTRow + 1
Do
If Left(Sheets("thisweek").Cells(lgTRow, 2).Value, 11) = "Team Totals" Then
Exit Do
End If
Sheets("thisweek").Cells(lgTRow, 2).Value = vbNullString
Sheets("thisweek").Cells(lgTRow, 4).Value = vbNullString
Sheets("thisweek").Cells(lgTRow, 7).Value = vbNullString
lgTRow = lgTRow + 1
Loop
Worksheets("thisweek").Activate 'Set Active Sheet
End Sub
____________________________________________________________
Thanks for the assist,
Gandalf
ActiveWorkbook.Xml doesn't work, what does?
URL of interest: Einstein@Home Team stats for XtremeSystems
Current code:
Public Sub CapTeamStats()
Dim lgRow As Long 'Row Index
Dim lgTRow As Long 'Row Index
Dim boSvWarn As Boolean 'Save Application Warning Value
Const coXTbl As String = "There are more active members than lastweek Members table allows" & _
vbNewLine & vbNewLine & "increase the size and rerun!"
'/*---------------------------------*/
'/* Declare Team Capture URL */
'/*---------------------------------*/
Const coTSURL As String = "http://stats.kwsn.net/team.php?proj=einstein&teamid=6105"
Worksheets("WCG").Activate 'Set Active Sheet
'/*---------------------*/
'/* Clear Capture Sheet */
'/*---------------------*/
Cells.Select 'Select Entire Sheet
Selection.ClearContents 'Clear Contents
Cells(1, 1).Select 'Select First Cell in Active Sheet
boSvWarn = Application.DisplayAlerts 'Save Warning Setting
Application.DisplayAlerts = False 'Suppress Warnings
ActiveWorkbook.XmlImport URL:=coTSURL, ImportMap:=Nothing, _
Overwrite:=True, Destination:=Range("$A$1") 'Import XML File
Application.DisplayAlerts = boSvWarn 'Restore Warning Setting
lgRow = 2 'Set Starting Row
Do While Cells(lgRow, 15).Value <> vbNullString
lgTRow = lgRow + 4
If Left(Sheets("thisweek").Cells(lgTRow, 2).Value, 11) = "Team Totals" Then
MsgBox coXTbl, vbOKOnly, "Error - Active Member Space" 'Notify User
Exit Sub
End If
Sheets("thisweek").Cells(lgTRow, 2).Value = Cells(lgRow, 4).Value 'Member Name
Sheets("thisweek").Cells(lgTRow, 4).Value = Cells(lgRow, 7).Value 'Total Credits
Sheets("thisweek").Cells(lgTRow, 7).Value = Cells(lgRow, 8).Value 'Average credits
lgRow = lgRow + 1
Loop
lgTRow = lgTRow + 1
Do
If Left(Sheets("thisweek").Cells(lgTRow, 2).Value, 11) = "Team Totals" Then
Exit Do
End If
Sheets("thisweek").Cells(lgTRow, 2).Value = vbNullString
Sheets("thisweek").Cells(lgTRow, 4).Value = vbNullString
Sheets("thisweek").Cells(lgTRow, 7).Value = vbNullString
lgTRow = lgTRow + 1
Loop
Worksheets("thisweek").Activate 'Set Active Sheet
End Sub
____________________________________________________________
Thanks for the assist,
Gandalf
Last edited: