How to Create a Text File using VB Script?
Using the File System Object method CreateTextFile we create a Text file and Using the GetFile Method we get the newly created file.
'Create a Text File using FSO or FileSystemObject
'Step 1: Create an object variable that interacts with the File System Object Library.
Set Fso = CreateObject("Scripting.FileSystemObject")
'Step 2: Use the CreateTextFile method along with the object to create a text file at desired location.
Fso.CreateTextFile("F:\Test.txt")
'Step 3: Use the GetFile method to get the newly created file and store in a variable called s.
Set s = fso.GetFile("F:\Test.txt")
'Step 4: Use the name method to get the file name and print it along with the message.
Msgbox "The Text Files Created is "&s.name
Back To File System Object Page
1 comment:
kiran what is the difference between FSO object and variable S I mean whether S is pointing to FSO when u perform Set s = fso.GetFile("F:\Test.txt")
Post a Comment