This example opens the Customer recordset of the Nwindex.mdb database, counts how many records are available, and enters this number on a new worksheet.
To create the Nwindex.mdb database, run the Microsoft Excel example for the CreateDatabase method.
Dim db As Database, rs As Recordset
Set db = Workspaces(0).OpenDatabase(Application _
.DefaultFilePath & "\NWINDEX.MDB")
Set rs = db.OpenRecordset("Customer")
Set resultsSheet = Worksheets.Add
With resultsSheet.Cells(1, 1)
.Value = "Records in " & rs.Name & " table:"
.Font.Bold = True
.EntireColumn.AutoFit
End With
rs.MoveLast
resultsSheet.Cells(1, 2).Value = rs.RecordCount
rs.Close
db.Close