K
Kou Vang
I am trying to an ADO to retrieve data from a text file, but keep running
into a problem. Do I need to attach a certain reference in order to work?
The VBA doesn't appear to be reading certain constants in the code.
Particularly the Jet OLEDB and the Wscript at the bottom. Thanks.
Option Explicit
Dim objConnection As ADODB.Connection
Dim objRecordset As ADODB.Recordset
Const adOpenStatic = 3
Const dLockOptimistic = 3
Const adCmdText = &H1
strPathtoTextFile = "n:\mds\tfa_sect\vc data forecast\vb\"
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoTextFile & ";" & _
"Extended Properties=""text;HDR=YES;FMT=Delimited"""
objRecordset.Open "SELECT * FROM TOTIS.txt", _
objConnection, adOpenStatic, adLockOptimistic, adCmdText
Do Until objRecordset.EOF
wscript.echo "SeqNum" & objRecordset.fields.Item("SeqNum")
wscript.echo "AADT" & objRecordset.fields.Item("AADT")
objRecordset.MoveNext
Loop
into a problem. Do I need to attach a certain reference in order to work?
The VBA doesn't appear to be reading certain constants in the code.
Particularly the Jet OLEDB and the Wscript at the bottom. Thanks.
Option Explicit
Dim objConnection As ADODB.Connection
Dim objRecordset As ADODB.Recordset
Const adOpenStatic = 3
Const dLockOptimistic = 3
Const adCmdText = &H1
strPathtoTextFile = "n:\mds\tfa_sect\vc data forecast\vb\"
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoTextFile & ";" & _
"Extended Properties=""text;HDR=YES;FMT=Delimited"""
objRecordset.Open "SELECT * FROM TOTIS.txt", _
objConnection, adOpenStatic, adLockOptimistic, adCmdText
Do Until objRecordset.EOF
wscript.echo "SeqNum" & objRecordset.fields.Item("SeqNum")
wscript.echo "AADT" & objRecordset.fields.Item("AADT")
objRecordset.MoveNext
Loop