Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FSO Error
#1
Solved: 11 Years, 4 Months ago
Hi All,
I've creating a text file and then trying to open that file for writing text into it but i'm getting error invalid procedure call.

Code:
Set fso=createobject("Scripting.FileSystemObject")
Set CFile=fso.createtextfile("c:\test.txt",true)
Set ofile=fso.opentextfile("c:\test.txt",forwriting,true) 'Here i'm getting
'error I've that file on my C drive I've tried Cfile.OpenTextFile
'Combination but that also not working
ofile.write("this is sample test data")&vbcrtl
ofile.write("making sure I've entered")

Thanks.
Reply
#2
Solved: 11 Years, 4 Months ago
used OpenAsTextStream(2, TristateUseDefault) 'forwriting default value is 2 and forreading default value is 1.
Now code will look like
Code:
set fso=createobject("scripting.FileSystemObject")
set f= fso.getfile(c:\test.txt")
set ofile=f.OpenAsTextStream(2, TristateUseDefault)
ofile.write "this is test" & Vbcrlf

But i want to try opentextfile command. Plz help on that.
Thanks
Reply
#3
Solved: 11 Years, 4 Months ago
Hi,
Your code is right ,but if you use 2 instead of for writing then it is going to wrokout.

Use these values then you will get it.
Forwriting --- 2
ForAppending--- 8
ForReading .... 1


Code:
Set fso=createobject("Scripting.FileSystemObject")
'Set CFile=fso.createtextfile("c:\test.txt",true)
Set ofile = fso.OpenTextFile("c:\\test.txt", 2, True)
ofile.write "this is sample test data"
ofile.write "making sure I've entered"
ofile.close

Regards
Sridhar
Reply
#4
Solved: 11 Years, 4 Months ago
Thanks Sridhar..
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading an Existing File using FSO prabhu656656 1 2,018 09-10-2009, 12:18 AM
Last Post: sreekanth chilam

Forum Jump:


Users browsing this thread: 1 Guest(s)