Answers for "Wait until file exists"

VBA
0

Wait until file exists

Const timeoutSeconds As Long = 128

Public Function https://stackoverflow.com/questions/37065764/how-to-check-until-file-exist(ByVal theFileName As String) As Boolean
    Dim startTime As Single
    startTime = Timer
    
    Do
        If FSO.FileExists(theFileName) Then
            WaitForFileToExist = True
            Exit Do
        End If

        DoEvents
        Application.Wait Now + TimeValue("0:00:01")
        
        timeElapsed = Timer - startTime
    Loop Until timeElapsed > timeoutSeconds 
End Function
Posted by: Guest on April-12-2022

Code answers related to "VBA"

Browse Popular Code Answers by Language