-1

It's weird that I'm finding ways to slow down my macro. Apart from Doevents and other time delay techniques, which are basically a workaround, is there a way through which we can get around the asynchronous execution. As in, I want the VBA code to behave like this:

start executing line 1>finish executing line 1>move to line 2;

Forgive if I'm wrong but currently it seems to follow:

Start executing line 1>without caring whether line 1 finished or not start executing line2
YowE3K
  • 23,852
  • 7
  • 26
  • 40
Arjeel
  • 148
  • 10

2 Answers2

0

If you are calling external programs (vbs, exe) then the vba isn't getting any feedback on the process at all. It calls the programs and moves on to the next line of code (the vba doesn't know if/when the external programs finishes). One way to slow this process down would be to put a application.wait or application.sleep between the calls, but that is also a workaround. Please post your actual code and perhaps we can troubleshoot further.

0

if the code is about refreshing data, use Refresh method with backgroundquery=False in a For Loop instead of RefreshAll.

For Each con In Me.Connections
    con.ODBCConnection.BackgroundQuery = False
    con.Refresh
Next
Volkan Yurtseven
  • 425
  • 3
  • 15