View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Alex[_28_] Alex[_28_] is offline
external usenet poster
 
Posts: 1
Default Reading CSV file from Excel (VBA)

Hi to all,

dont know if somebody can help me.
I have an excel sheet that is saved from xls to csv.

the sheet as this format :
MSC1 MSCA
MSC2 MSCB
MSC3 MSCC
MSC4 MSCD

each value in a column

When reading the file with the below code, it's seems
that it is skipping a line for each line it reads
ex : would read MSC2 then MSC4 and (with excel 2003 it
would be MSC1 then MSC4...)

Dim arrFileLines()
i = 0

Set objFSO = CreateObject("Scripting.FileSystemObject")
'Name of file saved from excel xls -- CSV
'To be outputed to another file name....
Set objFile = objFSO.OpenTextFile("C:\Temp\TempCN.csv", 1)

Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop

objFile.Close

For l = Ubound(arrFileLines) to LBound(arrFileLines) Step
1
' writting line to file
Next

Did anybody come in contact with the same problem and how
did you fix it or is there a better way to do this?

Thank you in advance.

Alex