Hello friends !
So subj:
I try to run scripts from VBA but it's not working:
[VBA]Sub OpenTextFileTest()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\testfile.txt", ForAppending, TristateFalse)
f.Write "Hello world!"
f.Close
End Sub[/VBA]
However I need to get numbers from Text file.
So try to modify another example from VBA help:
[VBA]Sub TextStreamTest()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateTextFile "c:\test1.txt" 'Create file
Set f = fs.GetFile("c:\test1.txt")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
s = ts.ReadLine
MsgBox s
ts.Close
End Sub[/VBA]
I think I need not create file but just open it. But can't find procedure for it !
Regards,
separator