On Error not catching problem with a web query

Why does "On Error" not seem to work in this case Once every few hundred iterations, there will be a failure, timeout, or resource not available error on the last line which invokes .Refresh BackgroundQuery:=False.

Any insights would be much appreciated.

Regards,

Brian

code excerpt...........................

On Error GoTo query3error

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q s=" & ticker, Destination:=Range("A1"))
.Name = "q s=" & ticker
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False ' was True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.webtables = webtables(trials - 1) ' was "16"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = True ' was False
.Refresh BackgroundQuery:=False
End With



Answer this question

On Error not catching problem with a web query

  • shyma

    Brian please use the VBA forum to post questions regarding Visual Basic For Applications...

    Moving thread to VBA



  • JamesCandyMan

    hi,

    I hope this doesn't seem daft but have you defined the query3error label



  • On Error not catching problem with a web query