ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   "On Error" not working for web queries (https://www.excelbanter.com/excel-programming/367879-error-not-working-web-queries.html)

Brian in London

"On Error" not working for web queries
 
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
--
Brian

Don Guillett

"On Error" not working for web queries
 
goto
http://groups.yahoo.com/group/xltraders/
join
look for donaldb36 as author and download a free file to do it all for you.


--
Don Guillett
SalesAid Software

"Brian in London" wrote in message
...
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
--
Brian





All times are GMT +1. The time now is 01:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com