Hello All,
I have a code that is supposed to check if a file is open and then call another sub (which sends an email) It is supposed to loop and check every 5 seconds but it doesn't seem to recognize when the file is in place. I'm sure it's just something simple I'm overlooking.
Any help is much appreciated!
I have a code that is supposed to check if a file is open and then call another sub (which sends an email) It is supposed to loop and check every 5 seconds but it doesn't seem to recognize when the file is in place. I'm sure it's just something simple I'm overlooking.
VBA Code:
Sub Detect_DAR()
Const MAX_WAIT_SECS As Long = 7200
Const WAIT_SECS As Long = 5
Dim hWnd As Long
Dim ans As VbMsgBoxResult
Dim endTime As Single
endTime = Timer + MAX_WAIT_SECS
Dim strFileName As String
Dim strFileExists As String
strFileName = Sheets(2).Range("D16").Value
strFileExists = Dir(strFileName)
Do
If strFileExists <> "" Then
Call DAR_Comp
Exit Sub
End If
If Timer > endTime Then
Call DQ_Fail
Exit Sub
Else
PauseMacro WAIT_SECS
End If
Loop
Call DQ_Unknown
End Sub
Any help is much appreciated!