object required error for Scripting.FileSystemObject
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: object required error for Scripting.FileSystemObject

  1. #1
    Join Date
    Dec 2012
    Posts
    20

    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...

  2. #2
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,832

    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
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    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.

  4. #4
    DataMiser is online now Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,832

    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.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Dec 2012
    Posts
    20

    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...

  6. #6
    Join Date
    Dec 2012
    Posts
    20

    Re: object required error for Scripting.FileSystemObject

    thank you so much for your response....

  7. #7
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    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".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center