CreateObject("Scripting.FileSystemObject") not working 
Author Message
 CreateObject("Scripting.FileSystemObject") not working

Hi,

I am trying to implement VBScript macro that will create a new text file.
Here is the code for it:

Sub NewFile
    Dim fso, a, className
    className = InputBox("Please enter the name of the new file.")
    Set fso = new CreateObject("Scripting.FileSystemObject")
    Set a = fso.CreateTextFile(className + ".txt", True)
    a.WriteLine("This is a test for a new text file.")
    a.Close
End

Damn!  It is so simple but doesn't work when I ran the macro.  Here is a
dialog box error messages:

C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\COMMON\MSDEV98\MACROS\MYMACROS.DSM
This macro file contained the following error and will be unloaded:
Line 3: Syntax error
Set fso = new CreateObject("Scripting.FileSystemObject")
Would you like to edit the file?

Please help me by telling me what I did wrong.
Callistus Chui



Mon, 02 Jul 2001 03:00:00 GMT  
 CreateObject("Scripting.FileSystemObject") not working
Try

set fso = createobject("scripting.filesystemobject")

That "new" syntax is JScript... I'm really surprised it worked in VBScript
from anywhere.

   ______
   ab/mvp

   www.desktop.on.ca
   www.swynk.com/friends/bertrand/


Quote:
>Hi,

>I am trying to implement VBScript macro that will create a new text file.
>Here is the code for it:

>Sub NewFile
>    Dim fso, a, className
>    className = InputBox("Please enter the name of the new file.")
>    Set fso = new CreateObject("Scripting.FileSystemObject")
>    Set a = fso.CreateTextFile(className + ".txt", True)
>    a.WriteLine("This is a test for a new text file.")
>    a.Close
>End

>Damn!  It is so simple but doesn't work when I ran the macro.  Here is a
>dialog box error messages:

>C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\COMMON\MSDEV98\MACROS\MYMACROS.DSM
>This macro file contained the following error and will be unloaded:
>Line 3: Syntax error
>Set fso = new CreateObject("Scripting.FileSystemObject")
>Would you like to edit the file?

>Please help me by telling me what I did wrong.
>Callistus Chui



Mon, 02 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. CreateObject("Scripting.FileSystemObject") doesnt work

2. CreateObject("Scripting.FileSystemObject")

3. CreateObject("Outlook.Application") does not work

4. Set filesys = CreateObject("Scripting.FileSystemObject")

5. CreateObject("Scripting.FileSystemObject") Error

6. ** ? concerning CreateObject("Scripting.FileSystemObject")

7. Set fs = CreateObject("Scripting.FileSystemObject")-error

8. CreateObject("Scripting.FileSystemObject") Error

9. ** ? concerning CreateObject("Scripting.FileSystemObject")

10. Set fso = Server.CreateObject("Scripting.FileSystemObject")

11. Trouble with CreateObject("Scripting.FileSystemObject")

12. Server.CreateObject("Scripting.FileSystemObject")

 

 
Powered by phpBB® Forum Software