I am trying to convert a flat file into Excel-readable format. We receive a text file which uses the tilde (~) as a field delimiter, and I want to convert it to one that uses tab character. I'm interested in running this command line, and I need to be flexible with the filenames, so I want to use the parameter VBScript I have the following for:
set ARJs Set the WScript.Arguments set = inf = Args (0) Setf = Args (1) Const ForReading = 1 Const ForWriting = 2 Set objFSO = SetObject ("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile (infile.Value, ForReading) strContents = objFile.ReadAll objFile.Close strContents = change (strContents, "~", vbTab) set objFile = objFSO.OpenTextFile (outfile for some reason, me required object: '[string: "infile.txt"]' em>. objFSO.OpenTextFile (infile, Forreading) In the form of logic, toasting does not seem to work. VBScript is my strong point, does anyone help? <
-
Command line parameters are wires and not objects, so use the set keyword for assignments There is no need to do this:
inf = Args (0) outf = Args (1)
-
Note that the above code already returns the parameter value, so there is no need to use .value , .toString etc. (Actually, doing so would result in a run-time error).
-
Your script has typo & mdash; inf and outf variables are later referred to as infile and outfile .
Comments
Post a Comment