Open each column of file as text


Posted by Ben Y on September 26, 2000 6:42 PM

I'm currently using this to open text files which have six columns of data:

ChDir "A:\"
Workbooks.OpenText FileName:="A:\sacramento.update2.001", Origin:=xlWindows _
, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=True, OtherChar:="|", FieldInfo:=Array(Array(1, 2 _
), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2), Array(6, 2))

How do I change the array formula so that I can open a file with any number of columns as text (e.g. FieldInfo:=Array(Array(n, 2))?

Posted by Ivan Moala on September 27, 2000 3:54 AM

Try leaving the FieldInfo:= option out
ie

ChDir "A:\"
Workbooks.OpenText FileName:="A:\sacramento.update2.001", Origin:=xlWindows _
, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=True, OtherChar:="|"


Ivan



Posted by Ben Y on September 27, 2000 4:58 PM

Thanks Ivan.
Leaving the FieldInfo option out formats all cells as "General". I'd like to be able to open all data into cells as text.

Ivan : Workbooks.OpenText FileName:="A:\sacramento.update2.001", Origin:=xlWindows _ : , StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _ : ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _ : , Space:=False, Other:=True, OtherChar:="|", FieldInfo:=Array(Array(1, 2 _ : ), Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2), Array(6, 2))