Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Opt Out of a Query.

I have a worksheet with a macro that grabs information from many URL sources.
The macro looks for information within the query date entries after a button
selection. What I would like to incorperate is a button to suspend the
macro. Or even better a message box stating the query is being compiled
with possibly a Cancel button.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 212
Default Opt Out of a Query.

You can add a userform, adding a label saying "The Queries are being
refreshed" and a commandbutton with caption.
Define a Public Variable at module level, named say - userCanc e.g.:
Public userCanc as Boolean. Then the commandbutton click code of the
userform
do
userCanc = True
Unload Me

In the code to refressh the Query, you should first show the form,
vbModeless.
D referesh one after another and between every refresh command check the
status
of the userCanc, it it is true then exit sub
e.g.:
If userCanc Then Exit Sub.

But even then the last refresh command given by your code will still be
refreshing.
To stop it you need to double click on the sphere appearing in the staus
bar,
which will show a dialog box where you can click on cancel refresh.

Sharad


"Nicholas" wrote in message
...
I have a worksheet with a macro that grabs information from many URL
sources.
The macro looks for information within the query date entries after a
button
selection. What I would like to incorperate is a button to suspend the
macro. Or even better a message box stating the query is being compiled
with possibly a Cancel button.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Opt Out of a Query.

If your query is in fact an Excel QueryTable, then you could check the
Refreshing property of each QueryTable.
To cancel a refreshing QueryTable, run the CancelRefresh method.

Sub AllQueryTablesCancelRefresh()
Dim qtb As QueryTable

For Each qtb In ActiveSheet.QueryTables
If qtb.Refreshing Then qtb.CancelRefresh
Next
End Sub


Function AnyQueryTablesRefreshing() As Boolean
Dim qtb As QueryTable, bln As Boolean

bln = False
For Each qtb In ActiveSheet.QueryTables
If qtb.Refreshing Then
bln = True
Exit For
End If
Next
AnyQueryTablesRefreshing = False
End Function


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Nicholas" wrote in message
...
I have a worksheet with a macro that grabs information from many URL
sources.
The macro looks for information within the query date entries after a
button
selection. What I would like to incorperate is a button to suspend the
macro. Or even better a message box stating the query is being compiled
with possibly a Cancel button.



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
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
Save data retreived from query without saving query Anthony Excel Discussion (Misc queries) 0 January 25th 06 07:17 PM
Stop to modify the SQL query manually entered into query ! Olivier Rollet Excel Programming 6 November 3rd 04 08:34 AM
Problem with .Background Query option of ODBC Query Shilps Excel Programming 0 April 19th 04 06:41 AM


All times are GMT +1. The time now is 10:15 PM.

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

About Us

"It's about Microsoft Excel"