07-16-2013, 09:19 PM
Hi
I have written the following code to get data from txt file into datatable
but iam getting the following error
I need help on this
Thank you all
I have written the following code to get data from txt file into datatable
Code:
Const ForReading =1
row=1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\ExcelFiles\TestReg.txt" , ForReading)
Dim afilelines()
i=0
Do until objFile.AtEndOfStream
ReDim Preserve afilelines(i)
afilelines(i) = objFile.ReadLine
i=i+1
Loop
objFile.Close
For Each strLine in afilelines
MyArray =Split(strLine, " ", -1,1)
For each sline in MyArray
DataTable.SetCurrentRow(row)
datatable("A" , dtglobalsheet) = sline
row=row+1
Next
Next
DataTable.ExportSheet "C:\ExcelFiles\Book1.xls" , 1
ExitRun
Code:
The set DataTable.Value operation failed. The <A> column does not exist.
Line (19): "DataTable("A" , dtGlobalSheet) = sline".
I need help on this
Thank you all