View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
CLamar CLamar is offline
external usenet poster
 
Posts: 7
Default Retrieve from Acces

Yes it is that I use is: Let me know how it works. Make sure u modify it to
accept you sheet names and path names

Dim DbFullName As String
Dim Cnct As String, Src As String
Dim Connection As ADODB.Connection
Dim Recordset As ADODB.Recordset
Dim Col As Integer

Cells.Clear

'Connects to the MS Access Database
Set Connection = New ADODB.Connection
Cnct = "Driver={Microsoft Access Driver
(*.mdb)};Dbq=C:\Pathname;Uid=Admin;Pwd=;"
Connection.Open ConnectionString:=Cnct

'Opens the recordset
Set Recordset = New ADODB.Recordset

With Recordset

'Copies the field names from the database into an Excel worksheet
For Col = 0 To Recordset.Fields.count - 1
Sheets("List").Range("A1").Offset(0, Col).Value =
Recordset.Fields(Col).Name
Next

'Copies the data inside the recordset into a worksheet
Sheets("List").Range("A1").Offset(1, 0).CopyFromRecordset
Recordset

End With
Set Recordset = Nothing
Connection.Close
Set Connection = Nothing
End Sub
"WayneR" wrote:

Hi,

Is there a way to retrieve infomration from a MS Access database and load a
spreadsheet?

--
WayneR