R
ragtopcaddy via AccessMonster.com
The following code fails to detect a txt file open in Notepad. After this
function is called, because it returns false, I have code that, inexplicably,
successfully kills the file. However, even after the code completes, I can
still see the "killed" file in the open Notepad application, while my code
shells out to notepad and opens the new file. This is all very bizarre. Does
anyone have an explanation for all of this?
Thanks,
Bill R
Function FileLocked(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
FileLocked = True
Err.Clear
End If
End Function
--
Bill Reed
"If you can't laugh at yourself, laugh at somebody else"
Message posted via AccessMonster.com
function is called, because it returns false, I have code that, inexplicably,
successfully kills the file. However, even after the code completes, I can
still see the "killed" file in the open Notepad application, while my code
shells out to notepad and opens the new file. This is all very bizarre. Does
anyone have an explanation for all of this?
Thanks,
Bill R
Function FileLocked(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
FileLocked = True
Err.Clear
End If
End Function
--
Bill Reed
"If you can't laugh at yourself, laugh at somebody else"
Message posted via AccessMonster.com