I'm getting an Invalid Procedure or Call error Code 800A0005
when attempting to use the FileSystemObject.OpenTextFile method.
My code snippet is
Function TextFileOpen(Filename,IOMode,Create)
Dim fso1, MyFile
Set fso1 = CreateObject("Scripting.FileSystemObject")
'Error occurs on next line!
Set MyFile=fso1.OpenTextFile(FileName, IOMode, Create) <--- Error
TextfileOpen=MyFile
End Function
This code from an example in the vbscript documentation doesn't get
the error:
Function ReadLineTextFile
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile("f:\temp\testfile.txt", ForWriting,
True)
MyFile.WriteLine "Hello world!"
MyFile.WriteLine "The quick brown fox"
MyFile.Close
Set MyFile = fso.OpenTextFile("f:\temp\testfile.txt", ForReading)
'MsgBox "tso is " & MyFile
ReadLineTextFile = MyFile.ReadLine ' Returns "Hello world!"
End Function
What am I missing?
Thanks