AnotherHiggins
Technical User
I've been teaching myself VBA over the last several months and am by no means a "coder", so please bear with me.
I've developed a macro that runs on a timer. Every morning it does some stuff in Access, saves and formats some Excel files, then sends several emails to various distribution groups via GroupWise. The problem is that I sometimes get an error on the .send line of code. I think that GroupWise just can't keep up with how fast the emails are being created and sent.
So I want to make the code pause for several seconds before sending each email. I've searched for and found threads about this, but haven't found a definitive answer to what I'm trying to accomplish.
I thought about something like this:
On my system, this takes between 14 & 15 seconds to run. It eats up a lot of system resources (as you'd expect). But since this is running early in the morning before I even get in, I don't really care about that.
so my question is: does this seem like a reasonable solution?
In thread181-77254, someone suggested using the following:
But in another thread, someone brought up the possibility that using the Sleep API wasn't safe in VBA?
I just want something simple that can be stuck into the macro.
Thanks in advance.
[tt]__________________________________________
My name is John, and I approved this post.[/tt]
To get the best answers fast, please read faq181-2886
I've developed a macro that runs on a timer. Every morning it does some stuff in Access, saves and formats some Excel files, then sends several emails to various distribution groups via GroupWise. The problem is that I sometimes get an error on the .send line of code. I think that GroupWise just can't keep up with how fast the emails are being created and sent.
So I want to make the code pause for several seconds before sending each email. I've searched for and found threads about this, but haven't found a definitive answer to what I'm trying to accomplish.
I thought about something like this:
Code:
For i = 1 To 500000000
Next i
so my question is: does this seem like a reasonable solution?
In thread181-77254, someone suggested using the following:
Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub test()
'...
Sleep (10000) 'to sleep 10 seconds
'...
End Sub
I just want something simple that can be stuck into the macro.
Thanks in advance.
[tt]__________________________________________
My name is John, and I approved this post.[/tt]
To get the best answers fast, please read faq181-2886