07-12-2013, 11:07 PM
Hi All
I have written the following code ti import data from excel to txt file
both excel and txt files exists in C drive with names sample.txt and Book1.xls
but iam getting the following error
I am not understanding it
Please I need help on this
Thanks
I have written the following code ti import data from excel to txt file
both excel and txt files exists in C drive with names sample.txt and Book1.xls
Code:
Dim obj_FSO, my_objFile, text_FilePath
Dim Obj_Excel, Excel_Filename, Excel_SheetName, Excel_Row, Excel_Col, v
text_FilePath = "C:\sample.txt"
Set obj_FSO = createObject("Scripting.FileSystemObject")
Set my_objFile = obj_FSO.OpenTextFile(text_FilePath, 8)
Excel_FileName = "C:\Book1.xls"
Excel_SheetName = "Sheet1"
Excel_Col =1
Set Obj_Excel = CreateObject("Excel.Application")
Obj_Excel.Workbooks.Open Excel_FileName
For i= 1 to 3
Excel_Row =1
v= Obj_Excel.ActiveWorkBook.Workssheets(Excel_SheetName).Cells(Excel_Row, Excel_Col)
my_objFile.WriteLine v
Next
Obj_Excel.ActiveWorkbook.save
Obj_Excel.ActiveWorkbook.Closes
Obj_Excel.Workbooks.Close
Obj_Excel.Application.Quit
Set Obj_Excel = Nothing
Wscript.Quit
my_objFile.Close
but iam getting the following error
Code:
File not found
Set my_objFile = obj_FSO.OpenTextFile(text_FilePath, 8)
I am not understanding it
Please I need help on this
Thanks