PDA

View Full Version : Open .csv from code



Djblois
02-01-2010, 08:09 AM
How can I change this to not be fixed width:

Workbooks.OpenText filename:=UsGrowersTextFile, _
Origin:=437, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _
Array(0, 1), Array(49, 1)), TrailingMinusNumbers:=True

I want it to be comma separated. However, it does not autocomplete for me to find the DataType for .csv

mdmackillop
02-01-2010, 10:46 AM
This works for me

Workbooks.Open Filename:="S:\telnos\outlook.csv"

Djblois
02-01-2010, 10:54 AM
mdmackillop,

that is not the issue (my fault) it opens but I want it to separate into different columns by commas not by Fixed Width - automatically. There are about 10 columns in the text file that need to separate by commas.

mdmackillop
02-01-2010, 11:23 AM
From Help File

(http://vbaexpress.com/forum/)Example (http://vbaexpress.com/forum/)

This example opens the file Data.txt and uses tab delimiters to parse the text file into a worksheet.
Workbooks.OpenText filename:="DATA.TXT", _ dataType:=xlDelimited, tab:=True (http://vbaexpress.com/forum/)
Try changing tab:=True to Comma:=True