Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieving data from Txt file into datatable
#1
Not Solved
Hi
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
but iam getting the following error

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
Reply


Messages In This Thread
Retrieving data from Txt file into datatable - by kriday - 07-16-2013, 09:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to append date to xls file using qtp datatable methods? yona34 1 1,481 05-04-2018, 08:56 PM
Last Post: Ankur
  dtLocalSheet empty even though excel file contains data cantorre 2 2,242 05-10-2017, 12:47 PM
Last Post: vidhi
  Grab multiple line data from log file haziqwebs 0 1,708 10-19-2016, 01:28 PM
Last Post: haziqwebs
  The DataTable.ExportSheet operation failed. Invalid file. Niraj 2 6,032 05-05-2015, 11:40 PM
Last Post: babu123
Smile Need to validate a .txt file and .jpeg image. aman8604 0 2,108 04-09-2015, 11:33 AM
Last Post: aman8604

Forum Jump:


Users browsing this thread: 1 Guest(s)