Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default how do i get the "RefreshAll" method to work in a macro

i can get it to work when i step through my macro, but not when i run the
whole macro. i've even tried to put a "wait" into the macro, but it waits
with "connecing to data source" in bottom left corner.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default how do i get the "RefreshAll" method to work in a macro

On Aug 2, 2:16 pm, sloan wrote:
i can get it to work when i step through my macro, but not when i run the
whole macro. i've even tried to put a "wait" into the macro, but it waits
with "connecing to data source" in bottom left corner.


What's the VB code you are using and where is it placed?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default how do i get the "RefreshAll" method to work in a macro

On Aug 2, 2:27 pm, KLZA wrote:
On Aug 2, 2:16 pm, sloan wrote:

i can get it to work when i step through my macro, but not when i run the
whole macro. i've even tried to put a "wait" into the macro, but it waits
with "connecing to data source" in bottom left corner.


What's the VB code you are using and where is it placed?


You can try this macro in your ThisWorkbook object..

Private Sub Workbook_Open()
me.RefreshAll
End Sub

Or you can create a macro named Auto_Open with the following code..

Sub Auto_Open()
ActiveWorkbook.RefreshAll
End Sub

Included wait...

Sub Auto_Open()
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10 'waits 10 seconds
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
ActiveWorkbook.RefreshAll
MsgBox "Refreshed!"
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default how do i get the "RefreshAll" method to work in a macro

THX that seems to work.

"KLZA" wrote:

On Aug 2, 2:27 pm, KLZA wrote:
On Aug 2, 2:16 pm, sloan wrote:

i can get it to work when i step through my macro, but not when i run the
whole macro. i've even tried to put a "wait" into the macro, but it waits
with "connecing to data source" in bottom left corner.


What's the VB code you are using and where is it placed?


You can try this macro in your ThisWorkbook object..

Private Sub Workbook_Open()
me.RefreshAll
End Sub

Or you can create a macro named Auto_Open with the following code..

Sub Auto_Open()
ActiveWorkbook.RefreshAll
End Sub

Included wait...

Sub Auto_Open()
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10 'waits 10 seconds
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
ActiveWorkbook.RefreshAll
MsgBox "Refreshed!"
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default how do i get the "RefreshAll" method to work in a macro

Make sure all your queries are configured to NOT do background queries. Then
the code should wait for the query to finish before proceeding.

--
Regards,
Tom Ogilvy



"sloan" wrote:

i can get it to work when i step through my macro, but not when i run the
whole macro. i've even tried to put a "wait" into the macro, but it waits
with "connecing to data source" in bottom left corner.



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
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running [email protected] Excel Programming 5 May 16th 07 08:18 PM
Error Help - Method "Range" of object "_Worksheet" failed. Alan Smith Excel Programming 3 March 15th 07 06:55 PM
ActiveWorkbook.RefreshAll deosn't work in shared mode, "calculate" doesn't either SK Excel Programming 2 February 1st 07 04:49 PM
What is Error "Method "Paste" of object "_Worksheet" failed? vat Excel Programming 7 February 17th 06 08:05 PM
Getting "compile error" "method or data member not found" on reinstall Bp Excel Programming 1 April 23rd 04 04:42 PM


All times are GMT +1. The time now is 12:14 AM.

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"