"On Error" not working for web queries

B

Brian in London

Why does "On Error" seem to make no difference? Once every few hundred web
queries will fail because of some timeout or webpage not being available but
the "On Error" doesn't seem to help. The error is always on the last line:
".Refresh BackgroundQuery:= False".

Any insight would be 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top