Hi
I have a spreadsheet which open a csv file and converts it to another csv format (processing the rows as it goes). All worked if I opened the input csv file with the statement:
Set wbIN = Workbooks.Open(Filename:="g:Trans.csv")
except that the second column is sometimes misinterpreted as a date e.g. account No "MAR1" is converted to a datevalue before I can get to it.
To get around this I have tried to open the input csv as follows:
Set wbIN = Workbooks.OpenText(Filename:="g:\Trans.csv", DataType:=xlDelimited, textQualifier:=xlTextQualifierDoubleQuote, ConsecutiveDelimiter:=False, Comma:=True, FieldInfo:=Array(Array(2, 2)))
but no matter what syntax I try I now get the compile error:
Expected Function or variable
with the .OpenText highlighted
What am I doing wrong? Please help, I am tearing my hair out here (and I haven't got much left to lose!). I have checked the MS help, the web etc etc but can't see what I have got wrong. I am sure it is obvious but.....
Many thanks
I have a spreadsheet which open a csv file and converts it to another csv format (processing the rows as it goes). All worked if I opened the input csv file with the statement:
Set wbIN = Workbooks.Open(Filename:="g:Trans.csv")
except that the second column is sometimes misinterpreted as a date e.g. account No "MAR1" is converted to a datevalue before I can get to it.
To get around this I have tried to open the input csv as follows:
Set wbIN = Workbooks.OpenText(Filename:="g:\Trans.csv", DataType:=xlDelimited, textQualifier:=xlTextQualifierDoubleQuote, ConsecutiveDelimiter:=False, Comma:=True, FieldInfo:=Array(Array(2, 2)))
but no matter what syntax I try I now get the compile error:
Expected Function or variable
with the .OpenText highlighted
What am I doing wrong? Please help, I am tearing my hair out here (and I haven't got much left to lose!). I have checked the MS help, the web etc etc but can't see what I have got wrong. I am sure it is obvious but.....
Many thanks