I've been hacking around VBA since Office 95
Most of my code is that old and has worked flawlessly up to 2003
I recall my code working in 2007 [OS was XP] as well but lost that in a fire.
So years back I got 2010 and every football preseason I work
countless hours trying to migrate my code only to retreat and
continue using ver.2003
This URL works as expected with the Power Query feature, selecting Table 1.
http://g.sportsdatabase.com/nfl/que...ite=home+and+season=2018&submit=++S+D+Q+L+!++
However, in VBA code or manually building a web query it does not work.
A 1004 error in VBA , at .Refresh BackgroundQuery:=False ,,,, or unable
to open / can not download when using the GUI method.
Additionally, when the IE pops up I must cancel out of several script errors in both 2003 and 2010, but still 2003 is successful and 2010 is not.
My gut tells me this is a security issue and every year I google the same
sequrity options and regedits over and over to no avail. But then why does the
Power Query work just fine?
Thanks for reading
My setup
Win 7 Pro 64
Excel 2010 32bit
Most of my code is that old and has worked flawlessly up to 2003
I recall my code working in 2007 [OS was XP] as well but lost that in a fire.
So years back I got 2010 and every football preseason I work
countless hours trying to migrate my code only to retreat and
continue using ver.2003
This URL works as expected with the Power Query feature, selecting Table 1.
http://g.sportsdatabase.com/nfl/que...ite=home+and+season=2018&submit=++S+D+Q+L+!++
However, in VBA code or manually building a web query it does not work.
A 1004 error in VBA , at .Refresh BackgroundQuery:=False ,,,, or unable
to open / can not download when using the GUI method.
Additionally, when the IE pops up I must cancel out of several script errors in both 2003 and 2010, but still 2003 is successful and 2010 is not.
Code:
Sub Button1_Click()
Dim f As Worksheet
Set f = Sheets("Sheet1")
With f.Range("A10:Y544").Clear
End With
Dim objWeb As QueryTable
Dim sWebTable As String
sWebTable = 4
Set objWeb = Sheets("Sheet1").QueryTables.Add( _
Connection:="URL;http://g.sportsdatabase.com/nfl/query?output=default&sdql=week%2C+date%2C+team%2C+o%3Ateam%2C+line+%40+week%3D1++and+site%3Dhome+and+season%3D2018&submit=++S+D+Q+L+%21++", _
Destination:=Sheets("Sheet1").Range("A10"))
With objWeb
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True 'was true 20120627
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = sWebTable
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True 'try false
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False ' was false
End With
Set objWeb = Nothing
End Sub
My gut tells me this is a security issue and every year I google the same
sequrity options and regedits over and over to no avail. But then why does the
Power Query work just fine?
Thanks for reading
My setup
Win 7 Pro 64
Excel 2010 32bit