View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default Web query returned no data - turn off annoying message pop ups!

hi
i have limited experience with web queries but considerable expeience with
database queries. so i am doing some guessing.
the code you posted....do you run this code each time you refresh. if so
then you are re-creating a new query each time the code runs. once a query is
established, after that all you need to do is refresh the data meaning you
don't need to run this code each time you want to refresh. in fact, it's not
refreshing....it's recreating a new query from scratch. i think(guess) that
may be the source of your problem.
right click the query table and click data range properties. all of the
setting you set up in the code should be there. if you have it set to refresh
every minute, then this should be automatic. no need to run the code again.
see this site for form details.
http://www.mrexcel.com/tip103.shtml

regards
FSt1

"christian_spaceman" wrote:

Hi all,

I've googled this a few times, but can't appear to find a solution.

I've just set up a spreadsheet which imports stock information. This
uses a webquery, refresehd once a minute, which is added through vba
and pasted below (bit horrible as it was recorded).

The stock name is in stockCell.value

Every so often, an error message pops up with "This web query returned
with no data... blah blah blah". Everything stops until I respond with
"OK" to this. Given that I want the macro to run constantly without my
babysitting it, it would be very useful to be able to turn this off.

Does anyone know how to do it? All I can think of is
application.displayalerts = false. I've put this in workbook_open and
it makes no difference. Given tha the web queries update automatically
once a minute, I'm not sure where to tackle this in the vba

Many thanks in advance,

Chris


ith ThisWorkbook.Sheets(stockCell.Value).QueryTables.A dd(Connection:=
_
"URL;http://uk.finance.yahoo.com/q?s=" &
stockCell.Value, Destination:=Range("A10"))
.Name = "q?s=" & stockCell.Value & "_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 1
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "9,13,15"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With ' end of With
ThisWorkbook.Sheets(StockCell.Value).QueryTables.A dd(Connection:= _