Sub readExcelRangeToTxt()
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
Dim i As Integer
Dim cell As String
Dim txtFile As String
txtFile = "C:\temp\test.txt"
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\temp\test.xlsx")
Set xlSheet = xlBook.Sheets("Sheet1")
For i = 1 To 10
cell = xlSheet.Range("A" & i).Value
WriteToTxtFile txtFile, cell
Next i
xlBook.Close
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
Sub WriteToTxtFile(ByVal txtFile As String, ByVal text As String)
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim fh As Object
Set fh = fso.OpenTextFile(txtFile, 8, True)
fh.WriteLine (text)
fh.Close
Set fh = Nothing
Set fso = Nothing
End Sub