Pause Code Execution

G

Guest

I have a workbook with an ON-OPEN VB sub that runs which refreshes a web
query, then saves, then closes. The code is below:
Range("B2").Select
Selection.QueryTable.Refresh BackgroundQuery:=False
DoEvents
ActiveWorkbook.Save

Application.DisplayAlerts = True
Application.Quit

I am not having problems with the workbook, but some of my users in other
locations with similar workbook are having problems (workbook opens and
saves, but seems to do so before the web query refreshes. Is there anything
else other than DoEvents that can be used to pause code execution?
 
D

Don Guillett

maybe

application.ENABLEEVENTS
Range("B2").QueryTable.Refresh BackgroundQuery:=False
ActiveWorkbook.Save
Application.Quit
 
H

Harald Staff

Application.Quit ?
Is your workbook the only thing your users use Excel for ?

Best wishes Harald
 

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

Top