H
Howie
Trying to open a text file using ADO, but don't want it
delimited(comma). When using the following code, it
automatically returns comma delimited recordset. If I
change the FMT=Delimited to FMT=Fixed, then the
RecordSet.Open fails.
I've also tried opening with text driver (see below) and
get same comma-delimited recordset.
Not much ADO experience, so I'm mostly cutting and pasting
these coneection strings.
Thanks.
'Open an ADO connection to the folder specified
Set oConn = CreateObject("ADODB.CONNECTION")
oConn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strFilePath & ";" & _
"Extended
Properties=""text;HDR=No;FMT=Delimited"""
'Get the recordset
Set oRS = CreateObject("ADODB.RECORDSET")
'Now actually open the text file and import into Excel
oRS.Open "SELECT * FROM " & strFilename, oConn,
adOpenStatic, adLockReadOnly, adCmdText
TEXT DRIVER OPEN
"Driver={Microsoft Text Driver (*.txt;
*.csv)};" & _
"Dbq=" & strFilePath & ";" & _
"Extensions=txt"
delimited(comma). When using the following code, it
automatically returns comma delimited recordset. If I
change the FMT=Delimited to FMT=Fixed, then the
RecordSet.Open fails.
I've also tried opening with text driver (see below) and
get same comma-delimited recordset.
Not much ADO experience, so I'm mostly cutting and pasting
these coneection strings.
Thanks.
'Open an ADO connection to the folder specified
Set oConn = CreateObject("ADODB.CONNECTION")
oConn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strFilePath & ";" & _
"Extended
Properties=""text;HDR=No;FMT=Delimited"""
'Get the recordset
Set oRS = CreateObject("ADODB.RECORDSET")
'Now actually open the text file and import into Excel
oRS.Open "SELECT * FROM " & strFilename, oConn,
adOpenStatic, adLockReadOnly, adCmdText
TEXT DRIVER OPEN
"Driver={Microsoft Text Driver (*.txt;
*.csv)};" & _
"Dbq=" & strFilePath & ";" & _
"Extensions=txt"