Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Which runs first, Workbook_Open() or external query refresh?

I want to process some data when the user opens a spreadsheet, but not
until an external Access query has been refreshed.

"Refresh data on file open..." has been checked in the data range
properties. But I think my Workbook_Open() code is running before auto
refresh happens.

Where is the best place to put code to ensure that it runs after the
external MS-Query has been updated?

As a last resort, I could have the user press a button after all data
has been refreshed, but that is messy.

Thanks in advance....
...df

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Which runs first, Workbook_Open() or external query refresh?

I did a quick test with a MsgBox in the Worksheet_Open event; this message
came up before the message "This book contains automatic queries..." so it
seems that Worksheet_Open comes before any queries refresh.
--
- K Dales


" wrote:

I want to process some data when the user opens a spreadsheet, but not
until an external Access query has been refreshed.

"Refresh data on file open..." has been checked in the data range
properties. But I think my Workbook_Open() code is running before auto
refresh happens.

Where is the best place to put code to ensure that it runs after the
external MS-Query has been updated?

As a last resort, I could have the user press a button after all data
has been refreshed, but that is messy.

Thanks in advance....
...df


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Which runs first, Workbook_Open() or external query refresh?

Hi,

When you think about it, probably makes sense that the workbook needs to
open before the query can be refreshed <g.

That said, QueryTable objects do have events that can be intercepted and
coded - specifically AfterRefresh and BeforeRefresh. I'd say that you're
looking for AfterRefresh. There is a catch though. The Excel VBA help topic
'Using Events with the QueryTable Object' states ...

"Before you can use events with the QueryTable object, you must first create
a new class module and declare a QueryTable object with events."

Could I suggest (respectfully of course <g) that a read through this topic
might be a good place to start. Please post back if you need something
further.

HTH, Cheers and Regards, Sean.

" wrote:

I want to process some data when the user opens a spreadsheet, but not
until an external Access query has been refreshed.

"Refresh data on file open..." has been checked in the data range
properties. But I think my Workbook_Open() code is running before auto
refresh happens.

Where is the best place to put code to ensure that it runs after the
external MS-Query has been updated?

As a last resort, I could have the user press a button after all data
has been refreshed, but that is messy.

Thanks in advance....
...df


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Which runs first, Workbook_Open() or external query refresh?

As Tom Ogilvy also replied under a different thread, the following KB article
is probably also very useful here.

http://support.microsoft.com/support.../q182/7/35.asp
XL97: How to Use the Query Before and AfterRefresh Events

Regards, Sean.

" wrote:

I want to process some data when the user opens a spreadsheet, but not
until an external Access query has been refreshed.

"Refresh data on file open..." has been checked in the data range
properties. But I think my Workbook_Open() code is running before auto
refresh happens.

Where is the best place to put code to ensure that it runs after the
external MS-Query has been updated?

As a last resort, I could have the user press a button after all data
has been refreshed, but that is messy.

Thanks in advance....
...df


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Which runs first, Workbook_Open() or external query refresh?

Thanks guys for the replies.

After posting that message, I had an idea, why not turn off "Refresh on
open" for the data range, and instead call a refresh function right
FROM workbook_open() - that way I can refresh first, then process away.
Calling ActiveWorkbook.RefreshAll from workbook_open() seems to do the
trick.

Thanks again.
....df

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
external data automatic refresh through macro/query Texas Tonie[_2_] Excel Discussion (Misc queries) 0 April 12th 07 07:52 PM
Query Refresh-Enable Automatic Refresh Dialogue Box Terri Excel Discussion (Misc queries) 0 May 6th 05 08:21 PM
Prompting to allow External Query Data Refresh Tim Baker Excel Discussion (Misc queries) 3 March 8th 05 11:29 AM
Timing of automatic query refresh and macro pivot table refresh dutty Excel Programming 2 December 1st 04 07:19 PM
Excel does not close from VB!! (when i refresh Refresh query with BackgroundQuery:=False) Anant[_2_] Excel Programming 1 August 6th 03 04:22 AM


All times are GMT +1. The time now is 02:41 AM.

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"