Skip to content

Instantly share code, notes, and snippets.

@DataSolveProblems
Last active June 19, 2019 06:50
Show Gist options
  • Save DataSolveProblems/f11d9972c685cc63a8c3bb3f2c909d78 to your computer and use it in GitHub Desktop.
Save DataSolveProblems/f11d9972c685cc63a8c3bb3f2c909d78 to your computer and use it in GitHub Desktop.
Sub Testing()
MsgBox "Is file open?: " & IsFileOpen("<File Path>")
End Sub
Public Function IsFileOpen(ByVal File_Path As String) As Boolean
Dim fileNum As Long, errNumber As Long
On Error Resume Next
fileNum = FreeFile()
Open File_Path For Input Lock Read As #fileNum
Close fileNum
errNumber = Err
On Error GoTo 0
Select Case errNumber
Case 0
IsFileOpen = False
Case 70
IsFileOpen = True
Case Else
Error errNumber
End Select
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment