K
Kevin
I am attempting to read information saved previously in a text file. I get a
permission denied error which leads me to believe the process which last
wrote information to the file still has control of the file. As far as I can
tell this process finished normally. That previous process wrote information
to the file and the information I expect has been written to the file, but it
is apparently not releasing the file handle. The module which writes
information to the file is as follows:
Public Function WriteToFile(FName As Variant, OWrite As Boolean, myWriteData
As Variant
'**********************************************************************************************
'Author:
'Date:
'Purpose: To create a file using the path and file name passed into the
routine using the fName variable.
'FName represents the filename to create which is to include the full path
to the file.
'OWrite is a boolean to indicate if the file is to be overwritten
'myWriteDate represents the data to be written to the file
'*******************************************************************
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s As Variant
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile(FName, OWrite)
Set f = fs.GetFile(FName)
Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)
ts.Write myWriteData
ts.Close
Set ts = Nothing
Set f = Nothing
Set fs = Nothing
End Function
permission denied error which leads me to believe the process which last
wrote information to the file still has control of the file. As far as I can
tell this process finished normally. That previous process wrote information
to the file and the information I expect has been written to the file, but it
is apparently not releasing the file handle. The module which writes
information to the file is as follows:
Public Function WriteToFile(FName As Variant, OWrite As Boolean, myWriteData
As Variant
'**********************************************************************************************
'Author:
'Date:
'Purpose: To create a file using the path and file name passed into the
routine using the fName variable.
'FName represents the filename to create which is to include the full path
to the file.
'OWrite is a boolean to indicate if the file is to be overwritten
'myWriteDate represents the data to be written to the file
'*******************************************************************
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s As Variant
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile(FName, OWrite)
Set f = fs.GetFile(FName)
Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)
ts.Write myWriteData
ts.Close
Set ts = Nothing
Set f = Nothing
Set fs = Nothing
End Function