checking if file is already opened
I want to check a file by name file_xml is already opened by using test partner code.
Can some one pls help me
Re: checking if file is already opened
Hari, this is what I use:
Function IsFileOpen(sFileName As String) As Boolean
Dim intFn As Integer
Dim lngErrNum As Long
intFn = FreeFile() ' Get a free file number.
' Attempt to open the file and lock it.
Open sFileName For Input Lock Read As intFn
Close intFn ' Close the file.
lngErrNum = Err.Number ' Save the error number that occurred.
' Report the error
Select Case lngErrNum
Case 0, 53
' No error occurred - File is NOT already open by another user.
IsFileOpen = False
IsFileOpen = True