View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NCSU_madman NCSU_madman is offline
external usenet poster
 
Posts: 1
Default Force Macro to wait till Refreshall is done


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 nex
command. I get a msg box that pops up writes "This action will cance
a pending Refresh Data Command. Continue?"

So if I say "yes" the data does not refresh but finishes macro but i
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

--
NCSU_madma
-----------------------------------------------------------------------
NCSU_madman's Profile: http://www.excelforum.com/member.php...fo&userid=1631
View this thread: http://www.excelforum.com/showthread.php?threadid=27702