ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pause Code Execution (https://www.excelbanter.com/excel-programming/364388-pause-code-execution.html)

Luke Bailey

Pause Code Execution
 
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?

Don Guillett

Pause Code Execution
 
maybe

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


--
Don Guillett
SalesAid Software

"Luke Bailey" wrote in message
...
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:

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?




Harald Staff

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

Best wishes Harald

"Luke Bailey" skrev i melding
...
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?





All times are GMT +1. The time now is 09:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com