View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Daniel Bonallack Daniel Bonallack is offline
external usenet poster
 
Posts: 110
Default Import Access data to text file rather than Excel

I have the below code (copied from this forum) to extract data from Access
and copy it to the active Excel worksheet.

What I want is for that last line to copy the data to a txt file, and save
that file with name "myText.txt" to L:\Storage\

Thanks in advance!
Daniel Bonallack
_____________________

' Open the connection
Set Connection = New ADODB.Connection
Cnct = "Provider=Microsoft.Jet.OLEDB.4.0; "
Cnct = Cnct & "Data Source=" & DBFullName & ";"
Connection.Open ConnectionString:=Cnct

' Create RecordSet
Set Recordset = New ADODB.Recordset

Recordset.Open Source:=SQLString, ActiveConnection:=Connection
Range("A1").CopyFromRecordset Recordset