Solved File Editing VBScript question.

December 28, 2013 at 12:22:56
Specs: Windows XP
How may I be able to open a text file, add text, and then close the file using VBScript? To make this easier, let me show you how I want it:

first the VBScript creates a file, with a name indicated by an input box, then it will open it up and add a line of text into it.

if you can help, please do,


See More: File Editing VBScript question.

Report •

December 29, 2013 at 11:28:05
✔ Best Answer
Const ForWriting = 2, MUseDefault = -2
Dim fso, ts, fileObj, FileName
Set fso = CreateObject("Scripting.FileSystemObject")
FileN = Inputbox("ENTER the TEXT file Name","ENTER the TEXT file Name","e:\something.txt")
fso.CreateTextFile FileN
Set fileObj = fso.GetFile(FileN)
Set ts = fileObj.OpenAsTextStream(ForWriting, MUseDefault)
ts.WriteLine "I have suceeded"

added pre tags

message edited by mikelinus

Report •
Related Solutions

Ask Question