Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default stop web query

Hi
My problem is the following: I use vba web query to download a large number
of tables from the web. It works fine but for some pages it occasionally
freezes while querying the web page. Since I am not sure how to stop it, I
was thinking there should be a way to stop the query if it takes too long to
download and have the code continue.
How can I do that ?

Thanks for your help,

Jeremy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default stop web query

Have not personally tried this on a web query but suppose it should work same
as for other kinds of query...

The resulting querytable has some properties and methods that can be used:
QueryTable.BackgroundQuery - this should be set to True so that Excel (and
your code) can still do things while waiting for the query results
QueryTable.Refreshing - tells you if the query is still refreshing (true) or
done (false)
QueryTable.CancelRefresh - to cancel refreshing

So you should be able to start the query and then use a loop (timed) to
check for a hung query:

Dim QuitTime as Date
QuitTime = Now() + TimeValue("00:02:00") - to give up after 2 minutes; this
can be set to your preference
' Now wait 'til the time has passed - OR we get results
' MyWebQueryTable should be set to be the querytable from your web query
While MyWebQueryTable.Refreshing and (Now() < QuitTime)
DoEvents ' Let Windows keep doing what it needs to do...
Wend
If MyWebQueryTable.Refreshing Then ' If we exceeded the set quit time...
MyWebQueryTable.CancelRefresh
MsgBox "Web Query Cancelled: Time limit exceeded!"
End If

- K Dales


"Jeremy Bertomeu" wrote:

Hi
My problem is the following: I use vba web query to download a large number
of tables from the web. It works fine but for some pages it occasionally
freezes while querying the web page. Since I am not sure how to stop it, I
was thinking there should be a way to stop the query if it takes too long to
download and have the code continue.
How can I do that ?

Thanks for your help,

Jeremy

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop automatic data reformat when refreshing a query RobC Excel Discussion (Misc queries) 0 July 23rd 08 05:14 PM
stop excel from shifting cells up when a query returns no data DrLostinExcel Excel Worksheet Functions 2 November 9th 04 05:44 PM
Stop to modify the SQL query manually entered into query ! Olivier Rollet Excel Programming 6 November 3rd 04 08:34 AM
How do I stop other circles in other cells to stop selecting? stauff Excel Worksheet Functions 2 October 29th 04 09:02 PM
How do I stop other circles in other boxes to stop selecting? stauff Excel Worksheet Functions 1 October 28th 04 10:27 PM


All times are GMT +1. The time now is 08:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"