Last active
June 19, 2019 06:50
-
-
Save DataSolveProblems/f11d9972c685cc63a8c3bb3f2c909d78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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