R
rico
Hi all,
i'm building a doc management datatbase. I need to able to check if a user
still has a file open before they check it in. I can do this for most files
but for txt files its proving very difficult because notepad doesn't do any
record locking.
So the code needs to search for the doc's file name in all open windows
title bars.
The closest i've got was this code i've found:
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) _
As Long
Then doing something like this:
Sub CheckNotepad()
Dim hwnd As Long
hwnd = FindWindow("Notepad", vbNullString)
If hwnd <> 0 Then
MsgBox "Notepad is running"
Else
MsgBox "Notepad is not running"
End If
End Sub
But this only checks if notepad is open. I have tried putting a null string
in the first variable of FindWindow and the filename of my file in the second
variable but i cant get it to work.
Can anyone tell me what i need to change, or any other solutions
TIA
Rico
i'm building a doc management datatbase. I need to able to check if a user
still has a file open before they check it in. I can do this for most files
but for txt files its proving very difficult because notepad doesn't do any
record locking.
So the code needs to search for the doc's file name in all open windows
title bars.
The closest i've got was this code i've found:
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" _
( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
) _
As Long
Then doing something like this:
Sub CheckNotepad()
Dim hwnd As Long
hwnd = FindWindow("Notepad", vbNullString)
If hwnd <> 0 Then
MsgBox "Notepad is running"
Else
MsgBox "Notepad is not running"
End If
End Sub
But this only checks if notepad is open. I have tried putting a null string
in the first variable of FindWindow and the filename of my file in the second
variable but i cant get it to work.
Can anyone tell me what i need to change, or any other solutions
TIA
Rico