Try this:


Code:
Private Declare Function lOpen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
Private Declare Function lClose Lib "kernel32" Alias "_lclose" (ByVal hFile As Long) As Long


Function IsFileAlreadyOpen(FileName As String) As Boolean

 Dim hFile As Long
 Dim lastErr As Long

 ' Initialize file handle And Error variable.
 hFile = -1
 lastErr = 0

 ' Open for for read And exclusive sharing.
 hFile = lOpen(FileName, &H10)

 ' If we couldn't Open the file, Get the last error.
 If hFile = -1 Then
    lastErr = Err.LastDllError
    Else
    ' Make sure we Close the file On success.
    lClose (hFile)
 End If

 ' Check for sharing violation error.
 sFileAlreadyOpen = (hFile = 1) And (lastErr = 32)

End Function