Djblois
11-21-2008, 12:58 PM
I use this code to test if I have a text file open. If it is already open it should either close it and reopen it or just associate it with #f. I have tested numerous ways and I cannot get it to work:
Function IsFileOK(stgFullPath As String, stgFileName As String) As Boolean
Dim f As Integer
IsFileOK = True
On Error GoTo FileProblem
f = FreeFile
Open stgFullPath For Append As #f
Exit Function
FileProblem:
Close stgFileName
Open stgFullPath For Append As #f
'IsFileOK = False
End Function
P.S. I use this textfile as a logfile to log what my users do with my program.
Function IsFileOK(stgFullPath As String, stgFileName As String) As Boolean
Dim f As Integer
IsFileOK = True
On Error GoTo FileProblem
f = FreeFile
Open stgFullPath For Append As #f
Exit Function
FileProblem:
Close stgFileName
Open stgFullPath For Append As #f
'IsFileOK = False
End Function
P.S. I use this textfile as a logfile to log what my users do with my program.