Write a script in VB to write all the lines of a Text File into an excel spreadsheet using FileSystemObject
VB Script to write all the lines of a text file in to a Excel spread sheet. There are two ways to write all the lines by opening an existing Text File and the second one to create a Text File and write some lines and then writing them in the Excel Sheet.
Method 1
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible=True
objExcel.workbooks.Add()
Const ForReading =1
Set FSO = CreateObject("Scripting.FileSystemObject")
Set file = FSO.OpenTextFile("F:\TestFolder\Text1.txt", 1)
x=1
Do Until File.AtEndOfStream
Line = File.ReadLine
objExcel.Cells(x,1) = Line
x=x+1
Loop
objFile.Close
Method 2
No comments:
Post a Comment