how do i get the "RefreshAll" method to work in a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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?
 
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
 
Make sure all your queries are configured to NOT do background queries. Then
the code should wait for the query to finish before proceeding.
 
THX that seems to work.

KLZA said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top