How to check whether the given file is locked
Posted on July 14, 2011
1 2 3 4 5 6 7 8 9 10 11 12 13 | 'File/Folder Handling - How to check whether the given file is locked Public Function fnFileLocked(ByVal strFileName As String) As Boolean On Error Resume Next ' If the file is already opened by another process, ' and the specified type of access is not allowed, ' the Open operation fails and an error occurs. Open strFileName For Binary Access Read Write Lock Read Write As #1 Close #1 ' If an error occurs, the document is currently open. If Err.Number <> 0 Then fnFileLocked = True End If End Function |