object required error for Scripting.FileSystemObject
am getting runtime error 424-object required on the bold line of following code:
****Dim fs, fname
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set fname = fs.CreateTextFile("D:\vb\myfile.txt", True)
fname.WriteLine ("something")
fname.Close
Set fname = Nothing
Set fs = Nothing*****
which object can possibly be required?any help?
thank you in advance...:)
Re: object required error for Scripting.FileSystemObject
Is this ASP code or VB6?
If it is VB6 then I would advise not using the FSO at all. There is no need for it, the built in functions for file I/O work much better and take fewer resources.
As for the object message, clearly it is referring to the FSO
Re: object required error for Scripting.FileSystemObject
If you get the Object required error, I'd think that the name "Server" is not defined.
Find out which object the name Server refers to. Maybe this object is not available within the scope of your code.
Re: object required error for Scripting.FileSystemObject
That is why I asked if it was ASP. Sever.CreateObject would be the common method when writing VB script as part of an ASP page but would not be used in a VB6 app.
Re: object required error for Scripting.FileSystemObject
Found this code in ASP file system tutorial and added it to a vb 6.0 program to write a text file during runtime.i now add the references --> microsoft scripting runtime, microsoft scriptlet library and microsoft script control.And changed the bold line into:
Code:
Set fs = New FileSystemObject
now its working....no error...
Re: object required error for Scripting.FileSystemObject
thank you so much for your response....
Re: object required error for Scripting.FileSystemObject
Fine. That's what I thought.
I dont know much about ASP, but when creation of an object fails you get a different error like "cannot create object".