Hi NCSU_madman,
There are a few ways to accomplish this without using a timer. First, you
could set the BackgroundQuery property of your QueryTable to False. That
will force synchronous refreshes (your code will wait for them).
If you want to maintain background refreshing of your queries, you could use
WithEvents to sink the events of the QueryTable (one of the events available
for this object is AfterRefresh. This involves using a Class Module and
WithEvents. Chip Pearson has a good explanation of how to use these on his
site
www.cpearson.com.
--
Regards,
Jake Marx
MS MVP - Excel
www.longhead.com
[please keep replies in the newsgroup - email address unmonitored]
NCSU_madman wrote:
Here is my code:
ActiveWorkbook.RefreshAll 'runs query from access and updates in excel
ActiveSheet.Calculate
ActiveWorkbook.Save 'where the macro fails
ActiveWorkbook.Close
-----------------------------
Problem is that the Refreshall does not complete and goes to the next
command. I get a msg box that pops up writes "This action will cancel
a pending Refresh Data Command. Continue?"
So if I say "yes" the data does not refresh but finishes macro but if
say "no" the macro does not finish.
I tried to enter a wait code:
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 30
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
but this does not help. Anyone have any suggestions?
Thanks!