wilkersons
asked on
VBScript Error: Invalid Procedure call or argument
Hi all,
I was trying to run a simple vbscript, in which i open a text file for reading. I tried this simple script and it gives a runtime error 800A0005. It works fine when i replace OpenTextFile with CreateTextFile. So, does that mean i have an older version of the scripting engine or am I missing something.
Dim filesys, testfile
Set filesys = CreateObject("Scripting.Fi leSystemOb ject")
Set testfile= filesys.OpenTextFile("c:\s omefile.tx t",ForRead ing,True)
testfile.WriteLine "Your text goes here."
testfile.Close
I have windows xp, vbscript version 5.6.
Thanks in advance
I was trying to run a simple vbscript, in which i open a text file for reading. I tried this simple script and it gives a runtime error 800A0005. It works fine when i replace OpenTextFile with CreateTextFile. So, does that mean i have an older version of the scripting engine or am I missing something.
Dim filesys, testfile
Set filesys = CreateObject("Scripting.Fi
Set testfile= filesys.OpenTextFile("c:\s
testfile.WriteLine "Your text goes here."
testfile.Close
I have windows xp, vbscript version 5.6.
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi cookre,
I was able to solve the problem.
Dim filesys, testfile
Constant ForWriting = 2
Set filesys = CreateObject("Scripting.Fi leSystemOb ject")
Set testfile= filesys.OpenTextFile("c:\s omefile.tx t",ForWrit ing,True)
testfile.Close
WScript.echo "Finished"
Needed to define the value for "ForWriting"
Thanks for your immediate response.
I was able to solve the problem.
Dim filesys, testfile
Constant ForWriting = 2
Set filesys = CreateObject("Scripting.Fi
Set testfile= filesys.OpenTextFile("c:\s
testfile.Close
WScript.echo "Finished"
Needed to define the value for "ForWriting"
Thanks for your immediate response.
I would say "better luck next time" - but who needs luck?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsstmoptionexplicit.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsstmoptionexplicit.asp
ASKER
I get the same error. It gives an error at the third statement.
Dim filesys, testfile
Set filesys = CreateObject("Scripting.Fi
Set testfile= filesys.OpenTextFile("c:\s
testfile.Close
WScript.echo "Finished"