View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Need help in VB6

Anu

Is it a CSVfile? If so, you could read it with ADO.

Public Sub GetData()
Dim oConn As Object
Dim oRS As Object
Dim sFilename As String
Dim sConnect As String
Dim sSQL As String

sFilename = "C:\MyTest\"
sConnect = "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=" & sFilename & ";" & _
"Extensions=asc,csv,tab,txt;"

sSQL = "SELECT First,Last From ADOTest.csv"

Set oRS = CreateObject("ADODB.Recordset")
oRS.Open sSQL, sConnect, adOpenForwardOnly, _
adLockReadOnly, adCmdText

If Not oRS.EOF Then
ActiveSheet.Range("A1").CopyFromRecordset oRS
Else
MsgBox "No records returned.", vbCritical
End If

oRS.Close
Set oRS = Nothing

End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"anu" wrote in message
ups.com...
hi AP,

i have only windows XP. it is just that the instrument can spit out so
much of data. i can only open it as a text file. is there any way i can
selct specific columns from .dat file
without changing it into excel?

Thanks
Anu