> SleepMilliSeconds    


Synopsis

Pause executing VBA to let something else happen, like wait for a form to close, or something external like Transfer Spreadsheet from Excel, or copy and move files. It is better to Sleep than to loop DoEvents because DoEvents is resource-intense and slows down the process you are waiting for.

CODE
' SleepMilliSeconds
' http://www.utteraccess.com/wiki/SleepMilliSeconds
' Code courtesy of UtterAccess Wiki
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
'
' You are free to use this code in any application,
' provided this notice is left unchanged.
'
' rev  date                          brief descripton
' 1.0  2019-07-16                    
'
'*************** Code Start *****************************************************
' Purpose  : wait a specified number of milliseconds using the Windows Sleep API  
'--------------------------------------------------------------------------------
'                              API Declaration
'--------------------------------------------------------------------------------
'
'declare Sleep API
#If VBA7 Then
  Private Declare PtrSafe Sub Sleep _
     Lib "kernel32"  _
     (ByVal dwMilliseconds As Long)
#Else
  Private Declare Sub Sleep _
     Lib "kernel32"  _
     (ByVal dwMilliseconds As Long)  
#End If

'--------------------------------------------------------------------------------
'                              SleepMilliSeconds
'--------------------------------------------------------------------------------
'
Public Sub SleepMilliSeconds( pnMilliseconds As Long)
'pause further execution for specified milliseconds
'1000 milliseconds = 1 second
  Sleep pnMilliseconds
End Sub
'*************** Code End *******************************************************

Creative Commons License
SleepMilliSeconds by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.