How to open CSV as text?
The fieldinfo is determinine the format of the cells and the format of the
cells in the worksheet. You are using 2 (xlTextFormat) in the fieldinfo
which says to use text formating but your cells in the worksheet are set to
general which is causing the zeroes to be eliminated. I would format the
cells in the worksheet to text before importing the data.
"LeeL" wrote:
Cannot get a CVS file to open formatted as text. Using below opens columns
with numbers formatted as general, losing preceding zeros. Any ideas?
Workbooks.OpenText Filename:="C:\Test\INVBAL.csv", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, Comma:=True, _
FieldInfo:=Array(Array(1, 2), Array(2, 2), Array(3, 2))
I tried to change the file extension to .txt, but the data is corrupted or
encoded when trying to open.
--
Thanks & Best Regards
|