In using a WebQuery, if I use a specific date, the macro works fine as follows
But when I want to go to a date relative to the current date as follows, it hangs up at
".Refresh BackgroundQuery:=False"
This worked at one time, but now it does not.
Thanks
LouLBI
Code:
Sub DerbyLane()
'
'
Sheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.derbylane.com/entriesresult/SP08-20-2014AENT.HTM", Destination _
:=Range("A1"))
.Name = "SP08-20-2014AENT"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = False
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
But when I want to go to a date relative to the current date as follows, it hangs up at
".Refresh BackgroundQuery:=False"
Code:
Sub DerbyLane()
'
'
Sheets.Add
Dim URL As String, theDate As Date
theDate = Date - 1 'yesterday, for example
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.derbylane.com/entriesresult/SP" & Format(theDate, "MM-DD-YYYY") & "eENT.AENT.HTM", Destination _
:=Range("A1"))
.Name = "SP08-20-2014AENT"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = False
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
This worked at one time, but now it does not.
Thanks
LouLBI