I am reading a file and need to out put all lines of the file to a separate row within in excel. Can some one help. currently I'm only getting the last row. Dim objFSO, strTextFile, strData, strLine, arrLines
CONST ForReading = 1
'name of the text file
strTextFile = "C:\Documents and Settings\SClark\Desktop\4010ControlOutput.txt"'Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")'Open the text file - strData now contains the whole file
strData = objFSO.OpenTextFile(strTextFile,ForReading).ReadAll'Split the text file into lines
arrLines = Split(strData,vbCrLf)Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "4010 Control"
'Step through the lines
For Each strLine in arrLines
strLineArray = Split(strLine,".TXT")
strLine = Trim(strLineArray(0)) &".TXT"
' wscript.echo strLine
objExcel.Cells(intRow, 1).Value = strLine
NextintRow = intRow + 1
'Cleanup
Set objFSO = Nothing
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |